Exemple #1
0
 public int AddAdditionalService(AdditionalService obj)
 {
     obj.DateUpdate = DateTime.Now;
     obj.DateAdd = DateTime.Now;
     obj.Suser = System.Web.Security.Membership.GetUser().ToString();
     db.AdditionalServices.AddObject(obj);
     db.SaveChanges();
     return (obj.AdditionalServiceID);
 }
 public ActionResult Create(AdditionalService obj)
 {
     try
     {
         if (ModelState.IsValid)
         {
             int id = db.AddAdditionalService(obj);
             return RedirectToAction("Index");
         }
     }
     catch (DataException ex)
     {
         ModelState.AddModelError("", ex.Message.ToString() + " Невозможно сохранить изменения. Попробуйте повторить действия. Если проблема повторится, обратитесь к системному администратору.");
     }
     return RedirectToAction("Index");
 }
Exemple #3
0
 public void DetachAdditionalService(AdditionalService obj)
 {
     db.AdditionalServices.Detach(obj);
 }
Exemple #4
0
 public dbActionResult EditAdditionalService(AdditionalService obj)
 {
     try
     {
         obj.DateUpdate = DateTime.Now;
         obj.Suser = System.Web.Security.Membership.GetUser().ToString();
         db.AdditionalServices.Attach(obj);
         db.ObjectStateManager.ChangeObjectState(obj, EntityState.Modified);
         db.SaveChanges();
         dbActionResult returnObj = new dbActionResult();
         returnObj.intResult = obj.AdditionalServiceID;
         returnObj.exConcur = null;
         returnObj.exData = null;
         return (returnObj);
     }
     catch (OptimisticConcurrencyException ex)
     {
         dbActionResult returnObj = new dbActionResult();
         returnObj.intResult = -1;
         returnObj.exConcur = ex;
         returnObj.exData = null;
         return (returnObj);
     }
     catch (DataException ex)
     {
         dbActionResult returnObj = new dbActionResult();
         returnObj.intResult = -2;
         returnObj.exConcur = null;
         returnObj.exData = ex;
         return (returnObj);
     }
 }
        public ActionResult Edit(AdditionalService obj)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    dbActionResult resultAction = new dbActionResult();
                    resultAction = db.EditAdditionalService(obj);
                    int id = resultAction.intResult;
                    if (id >= 0)
                    {
                        return RedirectToAction("Index");
                    }

                    if (id == -1)
                    {
                        db.DetachAdditionalService(obj);
                        AdditionalService oldObj = db.GetAdditionalService(obj.AdditionalServiceID);
                        ModelState.AddModelError("", "Ошибка параллельного доступа к данным. Если проблема повторится, обратитесь к системному администратору.");
                        if (oldObj.Description != obj.Description)
                            ModelState.AddModelError("Description", "Текущее значение: " + oldObj.Description.ToString());
                        obj.Timestamp = oldObj.Timestamp;
                    }
                    if (id == -2)
                    {
                        ModelState.AddModelError("", resultAction.exData.Message.ToString() + " | " + resultAction.exData.GetType().ToString() + " | " +
                            "Невозможно сохранить изменения. Нажмите обновить страницу и повторить действия. Если проблема повторится, обратитесь к системному администратору.");
                    }
                }
            }

            catch (DataException ex)
            {
                ModelState.AddModelError("", ex.Message.ToString() + " | " + ex.GetType().ToString() + " | " + "Невозможно сохранить изменения. Попробуйте повторить действия. Если проблема повторится, обратитесь к системному администратору.");
            }

            return View(obj);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the AdditionalServices EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToAdditionalServices(AdditionalService additionalService)
 {
     base.AddObject("AdditionalServices", additionalService);
 }
 /// <summary>
 /// Create a new AdditionalService object.
 /// </summary>
 /// <param name="additionalServiceID">Initial value of the AdditionalServiceID property.</param>
 public static AdditionalService CreateAdditionalService(global::System.Int32 additionalServiceID)
 {
     AdditionalService additionalService = new AdditionalService();
     additionalService.AdditionalServiceID = additionalServiceID;
     return additionalService;
 }