Ejemplo n.º 1
0
        public void Add(AddEditProjectInputModel input)
        {
            var dbModel = Mapper.Map <Project>(input);

            if (input.FileUploaded != null)
            {
                dbModel.ImageId = imageServices.Save(input.FileUploaded);
            }

            this.Data.Projects.Add(dbModel);
            this.Data.SaveChanges();
        }
Ejemplo n.º 2
0
        public void Save(AddEditProjectInputModel input)
        {
            var dbModel = Mapper.Map <Project>(input);

            if (input.FileUploaded != null)
            {
                // Delete the old image
                if (dbModel.ImageId != null)
                {
                    imageServices.Delete(dbModel.ImageId.Value);
                }

                dbModel.ImageId = imageServices.Save(input.FileUploaded);
            }

            this.Data.Projects.Update(dbModel);
            this.Data.SaveChanges();
        }