StreetFoo.Client.ReportItem.CreateReportItemAsync C# (CSharp) Method

CreateReportItemAsync() static private method

static private CreateReportItemAsync ( string title, string description, IMappablePoint point, IStorageFile image ) : Task
title string
description string
point IMappablePoint
image IStorageFile
return Task
        internal static async Task<ReportItem> CreateReportItemAsync(string title, string description, 
            IMappablePoint point, IStorageFile image)
        {
            var item = new ReportItem()
            {
                Title = title,
                Description = description,
                NativeId = Guid.NewGuid().ToString(),
                Status = ReportItemStatus.New
            };
            item.SetLocation(point);

            // save...
            var conn = StreetFooRuntime.GetUserDatabase();
            await conn.InsertAsync(item);

            // stage the image...
            if (image != null)
                await item.StageImageAsync(image);

            // return...
            return item;
        }

Usage Example

        protected override async Task DoSaveAsync()
        {
            // save...
            if (this.IsNew)
            {
                // create a new one...
                await ReportItem.CreateReportItemAsync(this.Item.Title, this.Item.Description, this.Item,
                                                       this.TempImageFile);
            }
            else
            {
                // update the existing data in SQLite...
                await this.Item.InnerItem.UpdateAsync(this.TempImageFile);
            }

            // cleanup...
            await this.CleanupTempImageFileAsync();

            // return...
            this.Host.GoBack();
        }