Пример #1
0
 public ActionResult DeleteSurveyType(SurveyTypeViewModel item)
 {
     try
     {
         SurveyType c = db.SurveyTypes.Find(item.ToModel().Id);
         if (c != null)
         {
             c.IsDeleted    = true;
             c.DeletionDate = DateTime.Now;
             db.SaveChanges();
         }
         return(new HttpStatusCodeResult(200));
     }
     catch
     {
         LogViewModel l = new LogViewModel
         {
             Id          = Guid.NewGuid(),
             CreatedDate = DateTime.Now,
             Type        = "Deletion",
             Message     = "failed to delete survey type " + this.Type + " to database"
         };
         l.AddLog(l);
         return(new HttpStatusCodeResult(400));
     }
 }
Пример #2
0
        public ActionResult UpdateSurveyType(SurveyTypeViewModel item)
        {
            try
            {
                SurveyType c = db.SurveyTypes.Find(item.ToModel().Id);
                if (c != null)
                {
                    c.Id             = item.Id;
                    c.DeletionDate   = item.DeletionDate;
                    c.DeletionUserId = item.DeletionUserId;
                    c.IsDeleted      = item.IsDeleted;
                    c.ModifiedDate   = DateTime.Now;
                    c.ModifiedUserId = item.ModifiedUserId;
                    c.Surveys        = this.GetSurveyList(item.Surveys);
                    c.Type           = item.Type;
                    //c.CreatedDate = item.CreatedDate;
                    c.CreatedUserId = item.CreatedUserId;

                    db.SaveChanges();
                }
                return(new HttpStatusCodeResult(200));
            }
            catch
            {
                LogViewModel l = new LogViewModel
                {
                    Id          = Guid.NewGuid(),
                    CreatedDate = DateTime.Now,
                    Type        = "Update",
                    Message     = "failed to update survey type " + this.Type + " to database"
                };
                l.AddLog(l);
                return(new HttpStatusCodeResult(400));
            }
        }
Пример #3
0
 public ActionResult AddSurveyType(SurveyTypeViewModel item)
 {
     try
     {
         SurveyType c = item.ToModel();
         c.Surveys     = item.GetSurveyList(item.Surveys);
         c.CreatedDate = DateTime.Now;
         db.SurveyTypes.Add(c);
         db.SaveChanges();
         return(new HttpStatusCodeResult(200));
     }
     catch
     {
         LogViewModel l = new LogViewModel
         {
             Id          = Guid.NewGuid(),
             CreatedDate = DateTime.Now,
             Type        = "Insertion",
             Message     = "failed to insert survey type " + this.Type + " to database"
         };
         l.AddLog(l);
         return(new HttpStatusCodeResult(400));
     }
 }