Ejemplo n.º 1
0
        public bool DeleteFacilityAttachment(InvFacilityAttachment facilityAttachment)
        {
            var success = true;

            try
            {
                using (var dbContext = new InventoryEntities())
                {
                    var existing = dbContext.InvFacilityAttachments
                                   .Where(x => x.ID == facilityAttachment.ID)
                                   .FirstOrDefault();
                    if (existing == null)
                    {
                        return(false);
                    }

                    dbContext.InvFacilityAttachments.Remove(existing);
                    dbContext.SaveChanges();
                }
            }
            catch (Exception e)
            {
                success = false;
            }

            return(success);
        }
Ejemplo n.º 2
0
        private AttachmentDetailViewModel InternalAddFacilityAttachment(InvFacility facility)
        {
            var attahcment = new InvFacilityAttachment()
            {
                ID            = Guid.NewGuid(),
                IsActive      = true,
                Title         = "Attachment-00",
                InvFacilityID = Model.SYNC_ID,
                CreatedBy     = _applicationContext.ActiveUser,
                CreatedOn     = DateTime.Now,
            }
            ;

            var eventAggreggor     = IoC.Get <IEventAggregator>();
            var windowManager      = IoC.Get <IInvWindowManager>();
            var facilityService    = IoC.Get <IFacilitiesService>();
            var applicationContext = IoC.Get <IApplicationContext>();
            var attachmentVm       = new AttachmentDetailViewModel(attahcment, applicationContext, eventAggreggor, _windowManager, _facilitiesService);
            var vm       = new AttachmentCreateViewModel(attachmentVm, eventAggreggor, windowManager);
            var settings = new Dictionary <string, object>
            {
                { "ResizeMode", ResizeMode.NoResize },
                { "WindowStartupLocation", WindowStartupLocation.CenterScreen }
            };

            if (windowManager.ShowDialog(vm, null, settings) ?? false)
            {
                return(attachmentVm);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 3
0
        public InvFacilityAttachment AddOrUpdateInvFacilityAttachment(InvFacilityAttachment facilityAttachment,
                                                                      bool addOrUpdate)
        {
            var success = true;
            InvFacilityAttachment saved = null;

            try
            {
                using (var dbContext = new InventoryEntities())
                {
                    if (addOrUpdate) // add
                    {
                        dbContext.InvFacilityAttachments.Add(facilityAttachment);
                    }
                    else // update
                    {
                        // shouldn't be here
                    }

                    dbContext.SaveChanges();
                    saved = dbContext.InvFacilityAttachments
                            .Where(x => x.ID == facilityAttachment.ID)
                            .FirstOrDefault();
                }
            }
            catch (Exception e)
            {
                saved = null;
            }

            return(saved);
        }