コード例 #1
0
 public ActionResult ActivityCreate(Activity_Master activityMaster)
 {
     try
     {
         activityMaster.Modified_by = Guid.Parse(Session["loginid"].ToString());
         _Base.Activity_Master_Add_Update(activityMaster);
         //var name = db.ActivityMasters.Where(p => p.Task == activityMaster.Task).Where(x => x.isActive == true).ToList();
         //if (name.Count == 0)
         //{
         //    //activityMaster.Activity_ID = Guid.NewGuid();
         //    activityMaster.isActive = false;
         //    activityMaster.Cre_on = DateTime.UtcNow;
         //    activityMaster.Cre_By = Guid.Parse(Session["loginid"].ToString());
         //    db.ActivityMasters.Add(activityMaster);
         //    db.SaveChanges();
         return(Json(activityMaster.Activity_ID, JsonRequestBehavior.AllowGet));
         //}
         //else
         //{
         //return Json("error");
         //}
     }
     catch (Exception)
     {
         throw;
     }
 }
コード例 #2
0
        public ActionResult Edit([Bind(Include = "ID,Name,Description,ShortName")] Activity_Master activity_Master)
        {
            try
            {
                //if (ModelState.IsValid)
                //{
                System.Collections.Generic.List <Activity_Master> getName = db.Activity_Master.Where(u => u.Name == activity_Master.Name && u.ID != activity_Master.ID).ToList();

                if (getName.Count > 0)
                {
                    ViewBag.message = ToasterMessage.Message(ToastType.info, "Record already exist");
                    return(View());
                }
                else
                {
                    db.Entry(activity_Master).State = EntityState.Modified;
                    db.SaveChanges();
                    TempData["message"] = ToasterMessage.Message(ToastType.success, "Updated Successfully");
                    return(RedirectToAction("Index"));
                }
                //}
            }
            catch (DbEntityValidationException e)
            {
                string errorMessage = string.Empty;

                foreach (DbEntityValidationResult eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);

                    foreach (DbValidationError ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                        errorMessage = ve.ErrorMessage;

                        ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage);
                    }
                }
                return(View());
            }
            catch (Exception)
            {
                ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong");
            }
            return(View());
        }
コード例 #3
0
        // GET: Activity_Master/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Activity_Master activity_Master = db.Activity_Master.Find(id);

            if (activity_Master == null)
            {
                return(HttpNotFound());
            }

            return(View(activity_Master));
        }
コード例 #4
0
        public ActionResult DeleteConfirmed(int id)
        {
            try
            {
                Activity_Master activity_Master = db.Activity_Master.Find(id);
                db.Activity_Master.Remove(activity_Master);
                db.SaveChanges();
                TempData["message"] = ToasterMessage.Message(ToastType.success, "Deleted successfully");
                return(RedirectToAction("Index"));
            }
            catch (DbEntityValidationException e)
            {
                string errorMessage = string.Empty;

                foreach (DbEntityValidationResult eve in e.EntityValidationErrors)
                {
                    Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                      eve.Entry.Entity.GetType().Name, eve.Entry.State);

                    foreach (DbValidationError ve in eve.ValidationErrors)
                    {
                        Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                          ve.PropertyName, ve.ErrorMessage);
                        errorMessage = ve.ErrorMessage;

                        ViewBag.message = ViewBag.message + ToasterMessage.Message(ToastType.error, errorMessage);
                    }
                }
                return(View());
            }
            catch (Exception)
            {
                ViewBag.message = ToasterMessage.Message(ToastType.error, "Something went wrong");
            }

            return(View());
        }