Esempio n. 1
0
        /// <summary>
        /// Deletes a Person.
        /// </summary>
        /// <param name="person"></param>
        public void Delete(tblPerson person)
        {
            //query to find person to delete
            //var person_to_delete =
            //from p in db.tblPersons
            //where p.PersonId == person.PersonId
            //select p;
            //tblPerson P = var;
            db.Entry(person).State = EntityState.Deleted;
            //db.tblPersons.Remove(person);

            //Persist to database.
            db.SaveChanges();
        }
        public IHttpActionResult PutEmployeeData(string id, EmployeeData employeeData)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employeeData.IdNumber)
            {
                return(BadRequest());
            }

            db.Entry(employeeData).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!EmployeeDataExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult PutSignUp(int id, SignUp signUp)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != signUp.Id)
            {
                return(BadRequest());
            }

            db.Entry(signUp).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!SignUpExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
 public ActionResult Edit(Employee emp)
 {
     using (EmployeesEntities db = new EmployeesEntities())
     {
         db.Entry(emp).State = EntityState.Modified;
         db.SaveChanges();
         return(Json(new { success = true, message = "Updated Successfully" }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 5
0
 public void UpdateEmployee(Shared.Entities.Employee emp)
 {
     using (var db = new EmployeesEntities())
     {
         db.Employees.Attach(emp);
         var entry = db.Entry(emp);
         entry.State = EntityState.Modified;
         db.SaveChanges();
     }
 }
 public ActionResult Edit([Bind(Include = "Id,FirstName,LastName,Email")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
 public ActionResult Edit([Bind(Include = "EmployeeId,Name,Gender,City,EmailId")] tblEmployee tblEmployee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tblEmployee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(tblEmployee));
 }
Esempio n. 8
0
 public ActionResult Edit([Bind(Include = "EmployeeID,Name,Position,Office,Age,Salary")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
Esempio n. 9
0
 public ActionResult Edit([Bind(Include = "EmployeeId,Name,HourlyWage,HoursWorked,Manager,Gross_Earnings,FWT,Net_earnings")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
Esempio n. 10
0
 public ActionResult Edit([Bind(Include = "EmployeeGuid,EmployeeNumber,FirstName,LastName,HireDate," +
                                          "TerminationDate,Type,Status,Shift,Department,Title")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
Esempio n. 11
0
        /// <summary>
        /// Persist the Person changes to the database.
        /// </summary>
        /// <param name="person"></param>
        public void Save(Person person)
        {
            tblPerson objPersonData = new tblPerson
            {
                PersonId  = person.PersonId,
                LastName  = person.LastName,
                FirstName = person.FirstName,
                BirthDate = new DateTime(person.BirthDate.Year, person.BirthDate.Month, person.BirthDate.Day)
            };

            // Since EF doesn't know about this product (it was instantiated by
            // the ModelBinder and not EF itself, we need to tell EF that the
            // object exists and that it is a modified copy of an existing row
            db.Entry(objPersonData).State = EntityState.Modified;

            db.SaveChanges();
        }
Esempio n. 12
0
        /// <summary>
        /// Persist changes to Employee to the database.
        /// </summary>
        /// <param name="employee"></param>
        public void Save(Employee employee)
        {
            //    public int EmployeeId { get; set; }
            //public int PersonId { get; set; }
            //public string EmployeeNumber { get; set; }
            //public System.DateTime EmployedDate { get; set; }

            //public Nullable<System.DateTime> TerminatedDate { get; set; }
            tblEmployee objPersonData = new tblEmployee
            {
                EmployeeId     = employee.EmployeeId,
                PersonId       = employee.PersonId,
                EmployeeNumber = employee.EmployeeNumber,
                EmployedDate   = new DateTime(employee.EmployedDate.Year, employee.EmployedDate.Month, employee.EmployedDate.Day)
            };

            // Since EF doesn't know about this product (it was instantiated by
            // the ModelBinder and not EF itself, we need to tell EF that the
            // object exists and that it is a modified copy of an existing row
            db.Entry(objPersonData).State = EntityState.Modified;

            db.SaveChanges();
        }
Esempio n. 13
0
        public ActionResult AddOrEdit(EmployeeTbl emp)
        {
            try
            {
                if (emp.ImageUpload != null)
                {
                    string fileName  = Path.GetFileNameWithoutExtension(emp.ImageUpload.FileName);
                    string extention = Path.GetExtension(emp.ImageUpload.FileName);
                    fileName  = fileName + DateTime.Now.ToString("yymmssfff") + extention;
                    emp.Image = "~/AppFiles/Images/" + fileName;
                    emp.ImageUpload.SaveAs(Path.Combine(Server.MapPath("~/AppFiles/Images/"), fileName));
                }

                using (EmployeesEntities db = new EmployeesEntities())
                {
                    if (emp.EmployeeId == 0)
                    {
                        db.EmployeeTbls.Add(emp);
                        db.SaveChanges();
                    }
                    else
                    {
                        db.Entry(emp).State = EntityState.Modified;
                        db.SaveChanges();
                    }
                }

                return(Json(new { success = true, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllEmployee()), message = "Submitted Successfully" },
                            JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false, html = GlobalClass.RenderRazorViewToString(this, "ViewAll", GetAllEmployee()), message = ex.Message },
                            JsonRequestBehavior.AllowGet));
            }
        }