예제 #1
0
        public async Task <IActionResult> PutDepartment(int id, Department department)
        {
            if (id != department.Id)
            {
                return(BadRequest());
            }

            _context.Entry(department).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!DepartmentExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #2
0
 public ActionResult WorklistEdit([Bind(Include = "")] work work)
 {
     if (Session["username"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     if (Session["uType"] == null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     if (ModelState.IsValid)
     {
         Db.Entry(work).State = EntityState.Modified;
         Db.SaveChanges();
     }
     return(RedirectToAction("Worklist"));
 }
예제 #3
0
        public ActionResult MakeAdmin(int id)
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (Session["uType"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            user user = dbContext.users.Find(id);

            user.type = "admin";

            if (ModelState.IsValid)
            {
                dbContext.Entry(user).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                dbContext.SaveChanges();
                return(RedirectToAction("UserList", "AdminUser"));
            }

            return(RedirectToAction("UserList", "AdminUser"));
        }
예제 #4
0
 /// <summary>
 /// Update record
 /// </summary>
 /// <param name="obj"></param>
 public void Update(T obj)
 {
     table.Attach(obj);
     db.Entry(obj).State = EntityState.Modified;
     Save();
 }
예제 #5
0
 public void Update(DataHeader entity)
 {
     db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
예제 #6
0
 public void Edit(T entity)
 {
     _db.Entry(entity).State = EntityState.Modified;
 }
예제 #7
0
 public virtual void Update(TEntity entityToUpdate)
 {
     dbSet.Attach(entityToUpdate);
     context.Entry(entityToUpdate).State = EntityState.Modified;
 }
예제 #8
0
        public ActionResult SaveWorkerData(HttpPostedFileBase file)
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (Session["uType"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var name             = Request["name"];
            var fathername       = Request["fathername"];
            var Phone            = Request["Phone"];
            var PresentAddress   = Request["PresentAddress"];
            var PermanentAddress = Request["PermanentAddress"];

            //var gender = gender.Items[gender.SelectedIndex].Text;
            Session["tempImage"] = file;
            var  gender          = Request["gender"];
            bool temporaryType   = (Request["temporaryType"] == "on") ? true : false;
            bool permanentType   = (Request["permanentType"] == "on") ? true : false;
            bool babyCareType    = (Request["babyCareType"] == "on") ? true : false;
            bool elderlyCareType = (Request["elderlyCareType"] == "on") ? true : false;

            var area  = Request["area"];
            var thana = getThanaString(area);
            var type  = getTypeString(temporaryType, permanentType, babyCareType, elderlyCareType);
            //var img = "defaultmaid.png";
            var img = Request["img"];;

            System.Diagnostics.Debug.WriteLine("-----TEN-------------------------------");
            System.Diagnostics.Debug.WriteLine(img);
            System.Diagnostics.Debug.WriteLine("-----Name-------------------------------");

            if (Session["tempImage"] != null)
            {
                Session.Remove("tempImage");

                var filename = Session["workerID"].ToString() + Path.GetExtension(file.FileName);
                var path     = Path.Combine(Server.MapPath("~/Content/Workers/"), filename);
                file.SaveAs(path);

                img = filename;
            }

            /*string sql = "UPDATE worker set Name = '" + name + "', fatherName = '" + fathername + "', mobile = '" + Phone + "', PresentAddress = '" + PresentAddress + "', PermanentAddress = '" + PermanentAddress + "', gender = '" + gender + "', type = '" + type + "', Area = '" + thana + "', image = '" + img + "' where WorkerId = '" + Session["workerID"] + "'";
             * DBHelper db = DBHelper.getDB();
             * db.setData(sql);*/

            int    id     = Int32.Parse(Session["workerID"].ToString());
            worker worker = dbContext.worker.Find(id);

            worker.Name             = name;
            worker.fatherName       = fathername;
            worker.mobile           = Phone;
            worker.PresentAddress   = PresentAddress;
            worker.PermanentAddress = PermanentAddress;
            worker.gender           = gender;
            worker.Area             = thana;
            worker.type             = type;
            worker.image            = img;

            if (ModelState.IsValid)
            {
                dbContext.Entry(worker).State = EntityState.Modified;
                dbContext.SaveChanges();
                //return RedirectToAction("Edit_Worker", "AdminWorker");
                return(RedirectToAction("Edit_Worker", new { workerID = Session["workerID"] }));
            }

            return(RedirectToAction("Edit_Worker", new { workerID = Session["workerID"] }));
        }
예제 #9
0
 public void Update(collect_data_view entity)
 {
     db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }