示例#1
0
 public ActionResult UpdateImage(ImageViewModel item)
 {
     try
     {
         Image c = db.Images.Find(item.ToModel().Id);
         if (c != null)
         {
             c.Id             = item.Id;
             c.IsDeleted      = item.IsDeleted;
             c.ModifiedDate   = DateTime.Now;
             c.ModifiedUserId = item.ModifiedUserId;
             c.DeletionDate   = item.DeletionDate;
             c.DeletionUserId = item.DeletionUserId;
             item.GetAnimateList(item.Animates, c.Animates);
             c.ImageType = db.ImageTypes.Find(item.ImageTypeId);
             c.Location  = item.Location;
             //c.CreatedDate = item.CreatedDate;
             c.CreatedUserId = item.CreatedUserId;
             c.ImageTypeId   = item.ImageTypeId;
             c.Name          = item.Name;
             c.Name          = item.Name;
             c.Height        = item.Height;
             c.Width         = item.Width;
             db.SaveChanges();
         }
         return(new HttpStatusCodeResult(200));
     }
     catch
     {
         LogViewModel l = new LogViewModel
         {
             Id          = Guid.NewGuid(),
             CreatedDate = DateTime.Now,
             Type        = "Update",
             Message     = "failed to update image " + this.Name + " to database"
         };
         l.AddLog(l);
         return(new HttpStatusCodeResult(400));
     }
 }
示例#2
0
 public ActionResult AddImage(ImageViewModel item)
 {
     try
     {
         Image i = item.ToModel();
         item.GetAnimateList(item.Animates, i.Animates);
         i.CreatedDate = DateTime.Now;
         db.Images.Add(i);
         db.SaveChanges();
         return(new HttpStatusCodeResult(200));
     }
     catch
     {
         LogViewModel l = new LogViewModel
         {
             Id          = Guid.NewGuid(),
             CreatedDate = DateTime.Now,
             Type        = "Insertion",
             Message     = "failed to insert image " + this.Name + " to database"
         };
         l.AddLog(l);
         return(new HttpStatusCodeResult(400));
     }
 }