public JsonResult Add(Employee employee)
        {
            db.Employees.Add(employee);
            db.SaveChanges();

            return(Json(JsonRequestBehavior.AllowGet));
        }
        public void SaveData(Employee model)
        {
            Employee Emp = new Employee
            {
                FirstName        = model.FirstName,
                LastName         = model.LastName,
                Gender           = model.Gender,
                EmailId          = model.EmailId,
                PhoneNo          = model.PhoneNo,
                Designation      = model.Designation,
                ReportingManager = model.ReportingManager,
                Address          = model.Address
            };

            try
            {
                Db.Employees.Add(Emp);
                Db.SaveChanges();
                Db.Dispose();
            }
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        var v = validationError.PropertyName + "," + validationError.ErrorMessage;
                    }
                }
            }
        }
예제 #3
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 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));
        }
예제 #5
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;
                    }
                }
            }
        }
예제 #6
0
 public ActionResult CreateEmployee(Employee employee)
 {
     if (employee != null)
     {
         _dBContext.Add(employee);
         _dBContext.SaveChanges();
     }
     return(Ok(employee));
 }
예제 #7
0
 public ActionResult Edit(Attendance attendance)
 {
     if (ModelState.IsValid)
     {
         db.Entry(attendance).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(attendance));
 }
        public ActionResult Create([Bind(Include = "id,name,surname,email,password,gender,student,worker")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
예제 #9
0
        public ActionResult Create([Bind(Include = "ID,Name,Abbreviation")] Currency currency)
        {
            if (ModelState.IsValid)
            {
                db.Currencies.Add(currency);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(currency));
        }
예제 #10
0
        public ActionResult Create([Bind(Include = "ID,FullName,Gender,DateOfBirth,PhoneNumber")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
예제 #11
0
        public ActionResult Create([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.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
예제 #12
0
        public ActionResult Create([Bind(Include = "PersonId,FirstName,LastName,Gender,Email,Mobile,Landline")] Person person)
        {
            if (ModelState.IsValid)
            {
                db.Persons.Add(person);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(person));
        }
예제 #13
0
        public ActionResult Create([Bind(Include = "PeopleID,FirstName,LastName,Gender,PeopleContactDetail")] People people)
        {
            if (ModelState.IsValid)
            {
                db.People.Add(people);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(people));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Age")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
        public ActionResult Create([Bind(Include = "ID,FirstName,LastName,HireDate,EmployeeID")] EmployeeModel employeeModel)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employeeModel);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employeeModel));
        }
예제 #16
0
        public ActionResult Create([Bind(Include = "ID,Name,Abbreviation")] OverTimeStatus overTimeStatus)
        {
            if (ModelState.IsValid)
            {
                db.OverTimeStatus.Add(overTimeStatus);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(overTimeStatus));
        }
예제 #17
0
        public ActionResult Create([Bind(Include = "ID,Name,Abbreviation")] BudgetArea budgetArea)
        {
            if (ModelState.IsValid)
            {
                db.BudgetAreas.Add(budgetArea);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(budgetArea));
        }
        public ActionResult Create([Bind(Include = "ID,Name,Abbreviation")] LegalCompany legalCompany)
        {
            if (ModelState.IsValid)
            {
                db.LegalCompanies.Add(legalCompany);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(legalCompany));
        }
예제 #19
0
        public ActionResult Create([Bind(Include = "ID, FirstName, LastName, IDCard, Photo, Address, Phone, Birthday, Relatives, Membership, Workplace, OfficeAddress, OfficePhone, IsActiveMember, JoinDate, ExitDate")] Member member)
        {
            if (ModelState.IsValid)
            {
                db.Member.Add(member);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(member));
        }
예제 #20
0
        public ActionResult Create([Bind(Include = "ID,National_ID,Sex,Fname,Mname,Lname,Mobile_number,Birth_date,Address,Job_position,Is_general_manager,Is_manager,Is_supervisor")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
예제 #21
0
        public ActionResult Create([Bind(Include = "id,FIRSTNAME,LASTNAME,USERNAME,STARTDATE,DEPARTMENT,SALES,RATING")] EmployeeModels employeeModels)
        {
            if (ModelState.IsValid)
            {
                db.Employee.Add(employeeModels);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employeeModels));
        }
예제 #22
0
        public ActionResult Create([Bind(Include = "EmployeeID,EmployeeName,Designation,Salary,CreateDate")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
예제 #23
0
        public ActionResult Create([Bind(Include = "EmployeeID,firstName,lastName,jobTitle,birthDate,hireDate,daysFirstCall,daysSecondCall,Email")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
예제 #24
0
        public ActionResult Create([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.Organizations.Add(organization);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(organization));
        }
예제 #25
0
        public ActionResult Create([Bind(Include = "ID,Achievement_name,Achievement_description,Achievement_completion_time,Achivement_date,Achievement_status")] Achievement achievement)
        {
            if (ModelState.IsValid)
            {
                db.Achievements.Add(achievement);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(achievement));
        }
예제 #26
0
        public ActionResult Create([Bind(Include = "EmployeeId,FirstName,LastName,Gender,Birth,Address,Phone")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(employee));
        }
        public ActionResult Create([Bind(Include = "StudentID,StudentName")] Student student)
        {
            if (ModelState.IsValid)
            {
                db.Students.Add(student);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(student));
        }
예제 #28
0
        public ActionResult Create([Bind(Include = "CourseID,CourseName")] Course course)
        {
            if (ModelState.IsValid)
            {
                db.Courses.Add(course);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(course));
        }
예제 #29
0
        public ActionResult Create([Bind(Include = "Id,Name,Location")] Department department)
        {
            if (ModelState.IsValid)
            {
                db.Departments.Add(department);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(department));
        }
        public ActionResult Create([Bind(Include = "ID,Name")] TrainingCategory trainingCategory)
        {
            if (ModelState.IsValid)
            {
                db.TrainingCategories.Add(trainingCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(trainingCategory));
        }