//public string GetEmployeeById(string EmployeeId) //{ // using (OrganizationEntities ON = new OrganizationEntities()) // { // var data = (from e in ON.EmployeeDetails // select new // { // e.EmployeeID, // e.EmployeeName, // e.EmailID, // e.Phone, // e.Salary, // e.City // }).Where(x=>x.EmployeeID == EmployeeId); // return jsonSerialiser.Serialize(data); // } //} public async Task <EmployeeDetail> GetEmployeeById(int EmployeeId) { OrganizationEntities OE = new OrganizationEntities(); EmployeeDetail emp = await OE.EmployeeDetails.FindAsync(EmployeeId.ToString()); return(emp); }
public void DeleteEmpliyee(string empid, string phone) { OrganizationEntities OE = new OrganizationEntities(); var employee = OE.EmployeeDetails.SingleOrDefault(x => x.EmployeeID == empid); OE.EmployeeDetails.Attach(employee); OE.EmployeeDetails.Remove(employee); OE.SaveChanges(); }
public void DeleteDepartment(string deptid, string empid) { OrganizationEntities OE = new OrganizationEntities(); var dept = OE.DepartmentDetails.SingleOrDefault(x => x.DepartmentID == deptid); OE.DepartmentDetails.Attach(dept); OE.DepartmentDetails.Remove(dept); OE.SaveChanges(); }
public void UpdateDepartment(string depid, string depname, int totalemployees) { OrganizationEntities OE = new OrganizationEntities(); var dept = OE.DepartmentDetails.SingleOrDefault(x => x.DepartmentID == depid); dept.DepartmentName = depname; dept.TotalEmployee = totalemployees; OE.SaveChanges(); }
public void AddNewEmployee(int empid, string empname, string emailId, int phone, int salary, string city) { OrganizationEntities NewOE = new OrganizationEntities(); var newEmp = new EmployeeDetail { EmployeeID = empid.ToString(), EmployeeName = empname, EmailID = emailId, Phone = phone.ToString(), Salary = Convert.ToInt32(salary), City = city }; NewOE.EmployeeDetails.Add(newEmp); NewOE.SaveChanges(); }
public void AddNewDepartment(string depid, string depname, int totalemployees, string empid) { OrganizationEntities NewOE = new OrganizationEntities(); var newDept = new DepartmentDetail { DepartmentID = depid, DepartmentName = depname, TotalEmployee = totalemployees, EmployeeID = empid }; NewOE.DepartmentDetails.Add(newDept); NewOE.SaveChanges(); }
public void UpdateEmployee(string empid, string empname, string emailId, string phone, int salary, string city) { OrganizationEntities OE = new OrganizationEntities(); var emp = OE.EmployeeDetails.SingleOrDefault(x => x.EmployeeID == empid); emp.EmployeeName = empname; emp.EmailID = emailId; emp.Phone = phone; emp.Salary = salary; emp.City = city; OE.SaveChanges(); }
public string GetDepartmentById(string DepartmentId) { using (OrganizationEntities ON = new OrganizationEntities()) { var data = (from d in ON.DepartmentDetails select new { d.DepartmentID, d.DepartmentName, d.TotalEmployee, d.EmployeeID }).Where(x => x.DepartmentID == DepartmentId); return(jsonSerialiser.Serialize(data)); } }
public string GetAllEmployeeData() { using (OrganizationEntities ON = new OrganizationEntities()) { var data = (from e in ON.EmployeeDetails select new { e.EmployeeID, e.EmployeeName, e.EmailID, e.Phone, e.Salary, e.City }); return(jsonSerialiser.Serialize(data)); } }