public IHttpActionResult PutDefectPicture(int id, DefectPicture defectPicture)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != defectPicture.PictureId)
            {
                return(BadRequest());
            }

            db.Entry(defectPicture).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DefectPictureExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult GetDefectPicture(int id)
        {
            DefectPicture defectPicture = db.DefectPictures.Find(id);

            if (defectPicture == null)
            {
                return(NotFound());
            }

            return(Ok(defectPicture));
        }
        public IHttpActionResult PostDefectPicture(DefectPicture defectPicture)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.DefectPictures.Add(defectPicture);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = defectPicture.PictureId }, defectPicture));
        }
        public IHttpActionResult DeleteDefectPicture(int id)
        {
            DefectPicture defectPicture = db.DefectPictures.Find(id);

            if (defectPicture == null)
            {
                return(NotFound());
            }

            db.DefectPictures.Remove(defectPicture);
            db.SaveChanges();

            return(Ok(defectPicture));
        }
Ejemplo n.º 5
0
        public async void UploadDefectPicture()
        {
            if (_vm.DefectTemplate.Pictures == null)
            {
                _vm.DefectTemplate.Pictures = new ObservableCollection <DefectPicture>();
            }
            var picture = new DefectPicture()
            {
                Picture = await ImgurPhotoUploader.UploadPhotoAsync()
            };

            _vm.DefectTemplate.Pictures.Add(picture);
            _vm.AddedDefectPictures.Add(picture);
        }
Ejemplo n.º 6
0
 public async void UploadDefectPhoto()
 {
     try
     {
         if (ApartmentViewModel.NewDefect.Pictures == null)
         {
             ApartmentViewModel.NewDefect.Pictures = new ObservableCollection <DefectPicture>();
         }
         var picture = new DefectPicture()
         {
             Picture = await ImgurPhotoUploader.UploadPhotoAsync()
         };
         ApartmentViewModel.NewDefect.Pictures.Add(picture);
     }
     catch (Exception e)
     {
         new MessageDialog(e.Message).ShowAsync();
     }
 }
        ////////// Constructor //////////
        public ApartmentViewModel()
        {
            ////////// Store Data From Interface instance //////////
            NewUser     = new User();
            NewResident = new Resident();

            NewDefect             = new Defect();
            NewDefectComment      = new DefectComment();
            SelectedDefectPicture = new DefectPicture();

            NewChangeComment       = new ChangeComment();
            SelectedChangeDocument = new ChangeDocument();
            NewChange = new Change();
            ////////// Handler //////////
            ApartmentHandler = new ApartmentHandler(this);
            ////////// Singletons //////////
            CatalogSingleton = CatalogSingleton.Instance;
            UserSingleton    = UserSingleton.Instance;
            ////////// User relay commands//////////
            UpdateUser      = new RelayCommand(ApartmentHandler.UpdateUser);
            UploadUserPhoto = new RelayCommand(ApartmentHandler.UploadUserPhoto);
            ////////// Resident relay commands//////////
            UploadResidentPhoto   = new RelayCommand(ApartmentHandler.UploadResidentPhoto);
            CreateResidentCommand = new RelayCommand(ApartmentHandler.CreateResident);
            DeleteResidentCommand = new RelayCommand(ApartmentHandler.DeleteResident);
            UpdateResidentCommand = new RelayCommand(ApartmentHandler.UpdateResident);
            ////////// Defect relay commands//////////
            UploadDefectPicture = new RelayCommand(ApartmentHandler.UploadDefectPhoto);
            DeleteDefectPicture = new RelayCommand(ApartmentHandler.DeleteDefectPicture);
            CreateDefect        = new RelayCommand(ApartmentHandler.CreateDefect, ApartmentHandler.CreateDefect_CanExecute);
            CreateDefectComment = new RelayCommand(ApartmentHandler.CreateDefectComment);
            ////////// changes relay commands//////////
            CreateChangeComment = new RelayCommand(ApartmentHandler.CreateChangeComment);
            DeleteChangePicture = new RelayCommand(ApartmentHandler.DeleteChangePicture);
            UploadChangePicture = new RelayCommand(ApartmentHandler.UploadChangePicture);
            CreateChange        = new RelayCommand(ApartmentHandler.CreateChange, ApartmentHandler.CreateChange_CanExecute);
        }