public ActionResult ServiceUpdate([Bind(Include = "ServiceId,ServiceName,ServiceDay,ServieAmount")] Servicess servicess)
 {
     if (ModelState.IsValid)
     {
         db.Entry(servicess).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("ServiceInformation"));
     }
     return(View(servicess));
 }
 public ActionResult ServiceAdd(Servicess servicess)
 {
     if (ModelState.IsValid)
     {
         db.Servicesses.Add(servicess);
         db.SaveChanges();
         return(RedirectToAction("ServiceInformation"));
     }
     return(View());
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 public static void AddOrUpdate(Servicess model)
 {
     try
     {
         var context = new DataContext();
         context.Services.Update(model);
         context.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="splited"></param>
        /// <param name="e"></param>
        private static void ServiceAddOrUpdate(string[] splited, MessageEventArgs e)
        {
            var servicess = new DataContext().Services.FirstOrDefault(f => EF.Functions.Like(f.Name.ToLower(), $"%{splited[1].ToLower()}%"));

            if (servicess != null)
            {
                servicess.Price = Convert.ToInt32(splited[2]);
                ServicesssDoService.AddOrUpdate(servicess);
                return;
            }
            var service = new Servicess();

            service.Name  = splited[1];
            service.Price = Convert.ToInt32(splited[2]);
            ServicesssDoService.AddOrUpdate(service);
        }
        public ActionResult ServiceUpdate(int?id)
        {
            int ab = Convert.ToInt32(Session["id"]);
            int bc = Convert.ToInt32(Session["Designation"]);

            if (ab != 0 && bc == 1)
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                Servicess ServiceUpdate = db.Servicesses.Find(id);
                if (ServiceUpdate == null)
                {
                    return(HttpNotFound());
                }
                return(View(ServiceUpdate));
            }
            else
            {
                FormsAuthentication.SignOut();
                return(RedirectToAction("Login", "Login"));
            }
        }