Exemplo n.º 1
0
 void OnItemSaved(SolutionItemSavedEventArgs e)
 {
     if (ParentFolder == null && ParentSolution != null)
     {
         ParentSolution.OnEntrySaved(e);
     }
     ItemSaved?.Invoke(this, e);
 }
        private async System.Threading.Tasks.Task saveInventoryItem()
        {
            if (SelectedCategory == null || string.IsNullOrEmpty(InventoryItem.InventoryItemName))
            {
                MessageHelper.ShowMessage("Name and category required!", "Validation");
                return;
            }


            IsBusy = true;
            try
            {
                if (SelectedVendor != null)
                {
                    InventoryItem.VendorId = SelectedVendor.VendorId;
                }
                if (SelectedCategory != null)
                {
                    InventoryItem.InventoryCategoryId = SelectedCategory.InventoryCategoryId;
                }
                var           toSave = InventoryItem.GetForSave <InventoryItem>();
                InventoryItem saved;
                if (toSave.InventoryItemId != null)
                {
                    saved = await DataService.PutItemAsync <InventoryItem>("inventoryItems", toSave.InventoryItemId.Value, toSave);
                }
                else
                {
                    saved = await DataService.PostItemAsync <InventoryItem>("inventoryItems", toSave);
                }
                InventoryItem.InventoryItemId = saved.InventoryItemId;
                InventoryItem.LastUpdated     = saved.LastUpdated;
                ItemSaved?.Invoke(InventoryItem, new EventArgs());
                MessagingCenter.Send <InventoryEditViewModel>(this, SUCCESS);
                IsBusy = false;
            }
            catch (Exception ex)
            {
                IsBusy = false;
                if (ex.InnerException != null)
                {
                    ex = ex.InnerException;
                }
                ExceptionHelper.ShowException(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemplo n.º 3
0
 private void Edit()
 {
     ItemEdited?.Invoke(this, new SomeEntityEventArgs {
         Entity = new SomeEntity
         {
             Id          = _id,
             Name        = Name,
             Description = Description,
             IsActive    = IsActive,
             Updated     = DateTime.Now
         }
     });
     ItemSaved?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 4
0
 private void Save()
 {
     ItemAdded?.Invoke(this, new SomeEntityEventArgs {
         Entity = new SomeEntity
         {
             Id          = Guid.NewGuid(),
             Name        = Name,
             Description = Description,
             IsActive    = IsActive,
             Updated     = DateTime.Now
         }
     });
     ItemSaved?.Invoke(this, EventArgs.Empty);
 }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            var  stars      = (byte)starsBoxRating.GetStars();
            var  performers = (List <Performer>)bindingSourcePerformers.DataSource;
            var  album      = textBoxAlbum.Text;
            uint trackNo    = 0;

            if (!string.IsNullOrWhiteSpace(textBoxTitleNr.Text))
            {
                uint.TryParse(textBoxTitleNr.Text, out trackNo);
            }
            uint year = 0;

            if (!string.IsNullOrWhiteSpace(textBoxYear.Text))
            {
                uint.TryParse(textBoxYear.Text, out year);
            }
            var comment = textBoxComment.Text;
            var genres  =
                (from object checkedItem in checkedListBoxGenre.CheckedItems select checkedItem.ToString()).ToArray();

            if (!_isMulti)
            {
                var savedFile = SaveToFile(_file.Name, stars, performers, album, trackNo, year, comment, genres);
                if (savedFile != null)
                {
                    ItemSaved?.Invoke(new KeyValuePair <string, File>(_file.Name, savedFile), new EventArgs());
                    pictureBox.Show();
                }
            }
            else
            {
                var returnList = new List <KeyValuePair <string, File> >();
                foreach (var filePath in _id3MultiEditHelp.TagList.Keys)
                {
                    _file = File.Create(filePath);
                    var savedFile = SaveToFile(filePath, stars, performers, album, trackNo, year, comment, genres);
                    if (savedFile != null)
                    {
                        returnList.Add(new KeyValuePair <string, File>(filePath, savedFile));
                    }
                }
                MultiItemSaved?.Invoke(returnList, new EventArgs());
                pictureBox.Show();
            }
        }
Exemplo n.º 6
0
        private void RaiseItemSaved(T @object)
        {
            var args = new ItemSavedEventArgs <T>(@object);

            ItemSaved?.Invoke(this, args);
        }
        private async System.Threading.Tasks.Task saveRequest()
        {
            if (Request.RequestedBy == null || string.IsNullOrEmpty(Request.RequestDescription))
            {
                MessageHelper.ShowMessage("Requested By and Description required!", "Validation");
                return;
            }

            if (await runTask(async() =>
            {
                var toSave = Common.Clone <MaintenanceRequest>(Request);
                if (toSave.AssignedTo != null)
                {
                    toSave.AssignedToId = toSave.AssignedTo.UserIdValue;
                }
                toSave.AssignedTo = null;
                if (toSave.RequestedBy != null)
                {
                    toSave.RequestedByIdValue = toSave.RequestedBy.UserIdValue;
                }
                toSave.AssignedTo = null;
                MaintenanceRequest saved = null;
                if (toSave.MaintenanceRequestId != null)
                {
                    saved = await DataService.PutItemAsync <MaintenanceRequest>("maintenanceRequests", toSave.MaintenanceRequestIdValue, toSave);
                }
                else
                {
                    saved = await DataService.PostItemAsync <MaintenanceRequest>("maintenanceRequests", toSave);
                }


                foreach (var ni in ImagesViewModel.NewImages)
                {
                    var filesToSend = new List <FileToSend>();
                    filesToSend.Add(new FileToSend()
                    {
                        Bytes = ni.ImageBytes,
                        FileName = Guid.NewGuid().ToString() + ".jpg",
                        ContentType = ni.MaintenanceRequestImage.ImageType
                    });

                    var results = await DataService.SendFiles <List <MaintenanceRequestImage> >($"maintenanceRequestImage/{saved.MaintenanceRequestIdValue}",
                                                                                                filesToSend, true);
                    ni.MaintenanceRequestImage.MaintenanceRequestImageIdValue = results[0].MaintenanceRequestImageIdValue;
                }

                if (NewReplies.Any())
                {
                    NewReplies.ForEach(nr => nr.MaintenanceRequestIdValue = saved.MaintenanceRequestIdValue);
                    var results = await DataService.PostAsync <List <MaintenanceRequestReply>, List <MaintenanceRequestReply> >($"maintenanceRequestReplys", NewReplies);
                    foreach (var result in results)
                    {
                        var nr = NewReplies.First(r => r.ReplyText == result.ReplyText && r.MaintenanceRequestReplyId == null);
                        nr.MaintenanceRequestReplyIdValue = result.MaintenanceRequestReplyIdValue;
                    }
                }

                foreach (var di in ImagesViewModel.DeletedImages)
                {
                    if (di.MaintenanceRequestImageId != null)
                    {
                        await DataService.DeleteItemAsync("maintenanceRequestImages", di.MaintenanceRequestImageIdValue);
                    }
                }

                Request.MaintenanceRequestId = saved.MaintenanceRequestId;
            }))
            {
                ItemSaved?.Invoke(Request, new EventArgs());
                MessagingCenter.Send <MaintenanceRequestEditViewModel>(this, SUCCESS);
            }
        }