public int CreateEmp(Employee_Master emp) { using (var context = new EmployeeEntities()) { Employee_Master emp1 = new Employee_Master() { Name = emp.Name, Date_Of_Birth = emp.Date_Of_Birth, Phone = emp.Phone, Address = emp.Address, Country = emp.Country_Info.Country_Id, State = emp.State_info.State_Id, City = emp.City_Info.City_Id, EmailId = emp.EmailId, IsActive = true, CreatedbY = Guid.NewGuid(), Createdon = DateTime.UtcNow, RoleId = emp.RoleMaster.RoleId, Password = emp.Password, }; context.Entry(emp1).State = EntityState.Added; context.SaveChanges(); return(emp1.EmpId); } }
public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employee_Master employee_Master = db.Employee_Master.Find(id); if (employee_Master == null) { return(HttpNotFound()); } ViewBag.City = new SelectList(db.City_Info, "City_Id", "City_Name", employee_Master.City); ViewBag.Country = new SelectList(db.Country_Info, "Country_Id", "Country_name", employee_Master.Country); ViewBag.RoleId = new SelectList(db.RoleMaster, "RoleId", "RoleName", employee_Master.RoleId); ViewBag.State = new SelectList(db.State_info, "State_Id", "State_Name", employee_Master.State); //ViewBag.Country1 = db.Country_Info.ToList(); //ViewBag.State1 = db.State_info.ToList(); //ViewBag.City1 = db.City_Info.ToList(); ViewBag.RoleId1 = db.RoleMaster.Where(x => x.isActive == true).ToList(); return(View(employee_Master)); }
public ActionResult DeleteConfirmed(int id) { Employee_Master employee_Master = db.Employee_Master.Find(id); db.Employee_Master.Remove(employee_Master); db.SaveChanges(); return(Json(employee_Master)); }
public HttpResponseMessage InsertEmployeeMaster(Employee_Master employeemaster) { employeemaster.Id = Guid.NewGuid(); var result = _employeeMasterService.InsertEmployee_Master(employeemaster); return(result ? toJson(null, OperatingState.Success, "添加成功") : toJson(null, OperatingState.Failure, "添加失败")); }
public HttpResponseMessage Put(int id, [FromBody] Employee_Master employee) { try { _employeesRepo.UpdateEmployee(id, employee); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } return(Request.CreateResponse(HttpStatusCode.OK)); }
public bool UpdateEmployee_Master(Employee_Master employeeMaster) { if (employeeMaster == null) { throw new ArgumentNullException("employeeMaster is null"); } bool result = _employeeMasterRepository.SingleUpdate(employeeMaster); return(result); }
public bool InsertEmployee_Master(Employee_Master employeeMaster) { if (employeeMaster == null) { throw new ArgumentNullException("employeeMaster is null"); } bool result = _employeeMasterRepository.Insert(employeeMaster); return(result); }
public HttpResponseMessage Post([FromBody] Employee_Master employee) { try { _employeesRepo.CreateEmployee(employee); } catch (Exception) { return(Request.CreateResponse(HttpStatusCode.InternalServerError)); } var message = Request.CreateResponse(HttpStatusCode.OK, employee); // This will show the url for the route set - for FindEmployeeById message.Headers.Location = new Uri(Url.Link("GetEmployeeById", new { id = employee.EmployeeId })); return(message); }
public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Employee_Master employee_Master = db.Employee_Master.Find(id); if (employee_Master == null) { return(HttpNotFound()); } return(View(employee_Master)); }
public void UpdateEmployee(int empId, Employee_Master employee) { var employeeObj = DbContext.Employee_Master.FirstOrDefault(x => x.EmployeeId == empId); if (employeeObj != null) { employeeObj.EmployeeDOJ = employee.EmployeeDOJ; employeeObj.EmployeeDepartment = employee.EmployeeDepartment; employeeObj.EmployeeDesignation = employee.EmployeeDesignation; employeeObj.EmployeeName = employee.EmployeeName; employeeObj.Gender = employee.Gender; DbContext.SaveChanges(); } }
public ActionResult Getdata() { List <Employee_Master> emplist = new List <Employee_Master>(); emplist = db3.GetData(); List <Employee_Master> emp2 = new List <Employee_Master>(); for (int i = 0; i < emplist.Count; i++) { Employee_Master emp3 = new Employee_Master(); emp3 = emplist[i]; emp2.Add(emp3); } // var emp2 = db2.GetRecord(); return(Json(emp2, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit(Employee_Master employee_Master) { if (ModelState.IsValid) { employee_Master.ModiefiedOn = DateTime.Now; employee_Master.ModifiedBy = Guid.NewGuid(); employee_Master.IsActive = true; db.Entry(employee_Master).State = EntityState.Modified; db.SaveChanges(); return(Json("success")); } ViewBag.City = new SelectList(db.City_Info, "City_Id", "City_Name", employee_Master.City); ViewBag.Country = new SelectList(db.Country_Info, "Country_Id", "Country_name", employee_Master.Country); ViewBag.RoleId = new SelectList(db.RoleMaster, "RoleId", "RoleName", employee_Master.RoleId); ViewBag.State = new SelectList(db.State_info, "State_Id", "State_Name", employee_Master.State); ViewBag.RoleId1 = db.RoleMaster.Where(x => x.isActive == true).ToList(); return(Json("Error")); }
public async Task <ActionResult> Create(Employee_Master emp3) { emp3.IsActive = true; emp3.CreatedbY = Guid.NewGuid(); emp3.Createdon = DateTime.Now; string emailmsg = "Your Email Id" + emp3.EmailId + ", is being registered with us" + "Kindly Check Your Credential For Login <br/> User Name:" + emp3.Name + "Password:"******"<br/> From:" + Resource1.Email_Account + "<br/> Phone No: 900324931"; string emailSubject = Resource1.Email_Subject + "Login Credential"; db.Employee_Master.Add(emp3); db.SaveChanges(); await this.SendEmail(emp3.EmailId, emailmsg, emailSubject); return(Json(emp3.EmpId)); }
private void SaveData(LifeLineDbContext context) { Employee_Master obj = new Employee_Master(); obj.firstName = string.IsNullOrWhiteSpace(txtFirstName.Text) ? null : txtFirstName.Text; obj.middleName = string.IsNullOrWhiteSpace(txtMiddleName.Text) ? null : txtMiddleName.Text; obj.lastName = string.IsNullOrWhiteSpace(txtLastName.Text) ? null : txtLastName.Text; obj.empAddress = string.IsNullOrWhiteSpace(txtAddress.Text) ? null : txtAddress.Text; obj.city = string.IsNullOrWhiteSpace(txtCity.Text) ? null : txtCity.Text; obj.stateId = ddlState.SelectedIndex == 0 ? null : (int?)Convert.ToInt32(ddlState.SelectedValue); obj.pincode = string.IsNullOrWhiteSpace(txtPincode.Text) ? null : txtPincode.Text; obj.phoneNumber = string.IsNullOrWhiteSpace(txtPhone.Text) ? null : txtPhone.Text; obj.mobileNumber = string.IsNullOrWhiteSpace(txtMobile.Text) ? null : txtMobile.Text; obj.emailAddress = string.IsNullOrWhiteSpace(txtEmail.Text) ? null : txtEmail.Text; obj.empStatus = string.IsNullOrWhiteSpace(ddlEmpStatus.SelectedValue) ? null : ddlEmpStatus.SelectedValue; obj.releasedOnDate = string.IsNullOrWhiteSpace(txtReleasedOn.Text) ? null : (DateTime?)DateTime.ParseExact(txtReleasedOn.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); obj.entryBy = SessionHelper.UserId; obj.entryDate = DateTime.Now; obj.updatedOn = null; context.AddToEmployee_Master(obj); }
public List <Employee_Master> GetData() { SqlConnection conn = new SqlConnection(AppSettingConnectionString.GetConnectionString("entity")); SqlCommand cmd = new SqlCommand("spSelectEmployee", conn); cmd.CommandType = System.Data.CommandType.StoredProcedure; conn.Open(); DataTable dt = new DataTable(); SqlDataAdapter da = new SqlDataAdapter(cmd); da.Fill(dt); conn.Close(); da.Dispose(); List <Employee_Master> emp = new List <Employee_Master>(); if (dt.Rows.Count > 0) { foreach (DataRow row in dt.Rows) { Employee_Master emp2 = new Employee_Master(); emp2.EmpId = Convert.ToInt32(row["EmpId"].ToString()); emp2.Name = row["Name"].ToString(); emp2.Phone = row["Phone"].ToString(); emp2.Date_Of_Birth = Convert.ToDateTime(row["Date_Of_Birth"].ToString()); emp2.Address = row["Address"].ToString(); emp2.EmailId = row["EmailId"].ToString(); emp2.Country = Convert.ToInt32(row["Country"].ToString()); emp2.State = Convert.ToInt32(row["State"].ToString()); emp2.City = Convert.ToInt32(row["City"].ToString()); emp.Add(emp2); } } return(emp); }
public void CreateEmployee(Employee_Master employee) { DbContext.Employee_Master.Add(employee); DbContext.SaveChanges(); }
public HttpResponseMessage UpdateEmployeeMaster(Employee_Master employeemaster) { var result = _employeeMasterService.UpdateEmployee_Master(employeemaster); return(result ? toJson(null, OperatingState.Success, "修改成功") : toJson(null, OperatingState.Failure, "修改失败")); }