Example #1
0
        public void Generate_OLB_Shifts(List <Employee> olbTeam)
        {
            DateTime startDate = new DateTime(2015, 1, 7);
            DateTime endDate   = new DateTime(2016, 1, 5);

            //int count = 0;

            while (startDate < endDate)
            {
                foreach (Employee person in olbTeam)
                {
                    Shift again = new Shift();

                    again.ShiftID    = shift_id++;
                    again.EmployeeID = person.EmployeeID;

                    again.ShiftDate    = startDate;//.AddDays(count);
                    again.ShiftPrimary = prim_or_sec;

                    db.Entry(again).State = EntityState.Added;
                    db.SaveChanges();

                    if (prim_or_sec == true)
                    {                           // switch back from primary to secondary
                        prim_or_sec = false;
                    }
                    else
                    {
                        startDate   = startDate.AddDays(7);
                        prim_or_sec = true;
                    }
                }
            }
        }
 public virtual void Delete(TEntity entityToDelete)
 {
     if (context.Entry(entityToDelete).State == EntityState.Detached)
     {
         dbSet.Attach(entityToDelete);
     }
     dbSet.Remove(entityToDelete);
 }
        public async Task <T> Create(T entity)
        {
            EntityEntry dbEntityEntry = employeeDBContext.Entry(entity);
            var         response      = await employeeDBContext.Set <T>().AddAsync(entity);

            await employeeDBContext.SaveChangesAsync();

            return(response.Entity);
        }
Example #4
0
 public ActionResult Edit(/*[Bind(Include = "PeopleID,FirstName,LastName,Gender,PeopleContactDetail")] */ People people)
 {
     if (ModelState.IsValid)
     {
         db.Entry(people).State = EntityState.Modified;
         db.Entry(people.PeopleContactDetail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(people));
 }
 //To Update the records of a particluar employee
 public void UpdateEmployee(Employee employee)
 {
     try
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch
     {
         throw;
     }
 }
        public IHttpActionResult PutEmployee(int id, Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employee.ID)
            {
                return(BadRequest());
            }

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

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

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public async Task <IActionResult> PutEmployee(int id, Employee employee)
        {
            employee.Id = id;


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

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

            return(NoContent());
        }
        public async Task <IActionResult> PutDepartment(int id, Department department)
        {
            if (id != department.DepartmentId)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #9
0
        public async Task <IActionResult> PutEmployee([FromRoute] int id, [FromBody] Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
        public ActionResult Edit(Employee emp)
        {
            var departments = db.Departments.ToList();

            ViewBag.Departments = new SelectList(departments, "Id", "Name");
            //  var errors = ModelState.Values.SelectMany(v => v.Errors);
            try
            {
                /*The ModelState.IsValid internally checks the Values.All(modelState =>
                 * modelState.Errors.Count == 0) expression..
                 * Because there was no input,the values collection will be empty
                 * so modelState.isvalid will return true..
                 */

                if (ModelState.IsValid)
                {
                    db.Entry(emp).State = EntityState.Modified;
                    int sv = db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(emp));
                }
            }
            catch (DataException /* de */)
            {
                ModelState.AddModelError("", "Unable to save changes .. Try again");
            }
            return(View(emp));
        }
        public async Task <IActionResult> PutECandidate(int id, ECandidate eCandidate)
        {
            if (id != eCandidate.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public ActionResult Edit(Department dp)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    /*EntityState is an Enumeration while an entity can be in any of the 5 states..
                     * These states are:Added,Unchanged,Modified,deleted or detached
                     * SaveChanges() work differently based on the entity state
                     * Modified entities Are updated in the database and then become unchanged
                     * when SaveChanges() returns
                     */

                    db.Entry(dp).State = EntityState.Modified;
                    int sv = db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(dp));
                }
            }
            catch (DataException /*de*/)
            {
                ModelState.AddModelError("", "Unable to save changes. Try again");
            }

            return(View(dp));
        }
Example #13
0
        public async Task <IActionResult> PutEmployeeInfo(string id, EmployeeInfo employeeInfo)
        {
            if (id != employeeInfo.Empid)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Example #14
0
        public IActionResult UpdateEmployee(Guid id, [FromBody] Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employee.Guid)
            {
                return(BadRequest());
            }

            employee.UpdateDate = DateTime.Now;
            _employeeContext.Entry(employee).State = EntityState.Modified;

            try
            {
                _employeeContext.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                if (!EmployeeExists(id))
                {
                    return(StatusCode((int)HttpStatusCode.NotFound, ex.Message));
                }
                else
                {
                    return(StatusCode((int)HttpStatusCode.InternalServerError, ex.Message));
                }
            }

            return(Ok(0));
        }
 public ActionResult Edit([Bind(Include = "StudentID,StudentName")] Student student)
 {
     if (ModelState.IsValid)
     {
         db.Entry(student).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(student));
 }
Example #16
0
 public ActionResult Edit([Bind(Include = "PersonId,FirstName,LastName,Gender,Email,Mobile,Landline")] Person person)
 {
     if (ModelState.IsValid)
     {
         db.Entry(person).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(person));
 }
Example #17
0
 public ActionResult Edit([Bind(Include = "ID,Achievement_name,Achievement_description,Achievement_completion_time,Achivement_date,Achievement_status")] Achievement achievement)
 {
     if (ModelState.IsValid)
     {
         db.Entry(achievement).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(achievement));
 }
Example #18
0
 public ActionResult Edit([Bind(Include = "id,FIRSTNAME,LASTNAME,USERNAME,STARTDATE,DEPARTMENT,SALES,RATING")] EmployeeModels employeeModels)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employeeModels).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employeeModels));
 }
Example #19
0
 public ActionResult Edit([Bind(Include = "EmployeeID,firstName,lastName,jobTitle,birthDate,hireDate,daysFirstCall,daysSecondCall,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 = "id,name,surname,email,password,gender,student,worker")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
 public ActionResult Edit([Bind(Include = "ID,Name")] TrainingCategory trainingCategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(trainingCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(trainingCategory));
 }
Example #22
0
 public ActionResult Edit([Bind(Include = "ID,FullName,Gender,DateOfBirth,PhoneNumber")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
Example #23
0
 public ActionResult Edit([Bind(Include = "EmployeeID,LastName,FirstName,MiddleName,Gender,BirthDate,Citizenship,Address1,Address2,City,ProvinceState,Country,PostalZip,HomePhone,MobilePhone,OfficePhone,HireDate,ContractEndDate,TerminationDate,EmergencyContactName,EmergencyContactRelationship,EmergencyContactNumber,YearsIndustryService")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
Example #24
0
 public ActionResult Edit([Bind(Include = "CourseID,CourseName")] Course course)
 {
     if (ModelState.IsValid)
     {
         db.Entry(course).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(course));
 }
 public ActionResult Edit([Bind(Include = "OrganizationID,Organization_Name,Organization_code,Is_Actv,Is_Del,Crtd_by,Crtd_ts,Mod_by,Mod_ts,RowVersion")] Organization organization)
 {
     if (ModelState.IsValid)
     {
         db.Entry(organization).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(organization));
 }
 public ActionResult Edit([Bind(Include = "ID, FirstName, LastName, IDCard, Photo, Address, Phone, Birthday, Relatives, Membership, Workplace, OfficeAddress, OfficePhone, IsActiveMember, JoinDate, ExitDate")] Member member)
 {
     if (ModelState.IsValid)
     {
         db.Entry(member).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(member));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Age")] Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(employee));
 }
Example #28
0
 public ActionResult Edit([Bind(Include = "ID,Name,Abbreviation")] Currency currency)
 {
     if (ModelState.IsValid)
     {
         db.Entry(currency).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(currency));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,Location")] Department department)
 {
     if (ModelState.IsValid)
     {
         db.Entry(department).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(department));
 }
Example #30
0
 public ActionResult Edit(Attendance attendance)
 {
     if (ModelState.IsValid)
     {
         db.Entry(attendance).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(attendance));
 }