Example #1
0
        public void PostEmployee(EmployeeContacts emp)
        {
            //var data = new Employee();

            using (IDbConnection db = new SqlConnection(_connectionString))
            {
                try
                {
                    var parameter = new DynamicParameters();
                    parameter.Add("@FirstName", emp.FirstName);
                    parameter.Add("@LastName", emp.LastName);
                    parameter.Add("@Address", emp.Address);
                    parameter.Add("@Email", emp.Email);
                    parameter.Add("@ContactNumber", emp.ContactNumber);
                    parameter.Add("@EmergyContactNumber", emp.EmergencyContactNumber);
                    parameter.Add("@Designation", emp.Designation);
                    parameter.Add("@Salary", emp.Salary);
                    parameter.Add("@WorkingHrPerDa", emp.WorkingHrPerDay);
                    parameter.Add("@IsFullTimer", emp.IsFullTimer);
                    parameter.Add("@Department", emp.Department);


                    db.Execute("InsertIntoContactsAndEmployee", parameter, commandType: CommandType.StoredProcedure);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Example #2
0
        public async Task <IActionResult> Edit(int id, [Bind("ContactId,MobileNumber,ResidentNo,EmployeeId")] EmployeeContacts employeeContacts)
        {
            if (id != employeeContacts.ContactId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employeeContacts);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeContactsExists(employeeContacts.ContactId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "FristName", employeeContacts.EmployeeId);
            return(View(employeeContacts));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "ID,ContactID,EmployeeID,QualificationsID,Name,Password,Position,StaffType,EmailAddress,BranchName,ContactInformation,EmergencyContact")] Employee employee,
                                   EmployeeContacts employeeContact, EmergencyContact emergencyContact, EmployeeQualifications qualify, Schedules schedule, string[] Qualifications, string ID, string Name)
        {
            if (ModelState.IsValid)
            {
                for (int i = 0; i < Qualifications.Length; i++)
                {
                    string results = Qualifications[i];
                    qualify.Qualifications = results;
                    qualify.EmployeeID     = ID;
                    db.EmployeeQualifications.Add(qualify);
                    db.SaveChanges();
                }

                employeeContact.EmployeeID  = ID;
                emergencyContact.EmployeeID = ID;
                //schedule.EmpId = Convert.ToInt32(ID);

                db.SaveChanges();

                db.Employees.Add(employee);
                db.EmployeeContacts.Add(employeeContact);
                db.EmergencyContact.Add(emergencyContact);

                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View());
        }
Example #4
0
        public ActionResult DeleteConfirmed(string id)
        {
            EmployeeContacts employeeContacts = db.EmployeeContacts.Find(id);

            db.EmployeeContacts.Remove(employeeContacts);
            db.SaveChanges();
            return(RedirectToAction("Index" + employeeContacts.EmployeeID));
        }
Example #5
0
 public ActionResult Edit([Bind(Include = "EmployeeID,Name,PhoneNumber,City,PostalCode,StreetAddress")] EmployeeContacts employeeContacts)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employeeContacts).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index/" + employeeContacts.EmployeeID));
     }
     return(View(employeeContacts));
 }
        public async Task <IActionResult> PostEmployees([FromBody] EmployeeContacts employees)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _employee.PostEmployee(employees);

            return(CreatedAtAction("GetEmplooyes", new { id = employees.EmployeeID }, employees));
        }
Example #7
0
        public async Task <IActionResult> Create([Bind("ContactId,MobileNumber,ResidentNo,EmployeeId")] EmployeeContacts employeeContacts)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employeeContacts);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"] = new SelectList(_context.Employees, "EmployeeId", "Fullname", employeeContacts.EmployeeId);
            return(View(employeeContacts));
        }
Example #8
0
        // GET: EmployeeContacts/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            EmployeeContacts employeeContacts = db.EmployeeContacts.Find(id);

            if (employeeContacts == null)
            {
                return(HttpNotFound());
            }
            return(View(employeeContacts));
        }
        public async Task <IActionResult> PutEmployees([FromRoute] int id, [FromBody] EmployeeContacts employees)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != employees.ContactID)
            {
                return(BadRequest());
            }

            _employee.PutEmployee(employees);



            return(Ok());
        }
Example #10
0
        public ActionResult Edit([Bind(Include = "ID,ContactID,EmployeeID,QualificationsID,Name,Password,Position,StaffType,EmailAddress,BranchName,Qualifications")] Employee employee,
                                 EmployeeContacts employeeContact, EmergencyContact emergencyContact, EmployeeQualifications qualify, string[] Qualifications, string id)
        {
            if (ModelState.IsValid)
            {
                for (int i = 0; i < Qualifications.Length; i++)
                {
                    string results = Qualifications[i];
                    qualify.Qualifications = results;
                    qualify.EmployeeID     = id;
                    db.EmployeeQualifications.Add(qualify);
                    db.SaveChanges();
                }

                employeeContact.EmployeeID  = id;
                emergencyContact.EmployeeID = id;

                db.Entry(employee).State         = EntityState.Modified;
                db.Entry(employeeContact).State  = EntityState.Modified;
                db.Entry(emergencyContact).State = EntityState.Modified;
                db.Entry(qualify).State          = EntityState.Modified;

                try
                {
                    db.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    //Safely ignore this exception
                }
                catch (Exception e)
                {
                    //Something else has occurred
                }

                return(RedirectToAction("Index"));
            }
            //return View(employee);
            return(View(employee));
        }