Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface IEmployeeService
- {
- [OperationContract]
- [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json,
- RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped ,
- UriTemplate = "getEmployee/")]
- List<EmployeeEntity> getEmployee();
- [OperationContract]
- [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json,
- RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,
- UriTemplate = "getEmployeeFromDb/")]
- List<Student> getEmployeeFromDb();
- [OperationContract]
- [WebInvoke(Method = "DELETE", ResponseFormat = WebMessageFormat.Json,
- RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped,
- UriTemplate = "/DeleteEmployee")]
- string DeleteEmployee(string Id);
- }
- public string DeleteEmployee(string Id)
- {
- int iEmpId = 0; int.TryParse(Id, out iEmpId);
- if (iEmpId > 0)
- {
- StudentEntityModel Db = new StudentEntityModel();
- Student Std = Db.Student.Where(w => w.Sid == iEmpId).FirstOrDefault();
- if(Std !=null)
- {
- Db.Student.Remove(Std);
- Db.SaveChanges();
- return "Deleted";
- }
- else { return "Failed."; }
- } else { return "Failed."; }
- }
- public List<EmployeeEntity> getEmployee()
- {
- return new List<EmployeeEntity> {
- new EmployeeEntity {Sid=1,Name="Muruganvc", Gender="Male" , Email="muruganvc@gmail.com" },
- new EmployeeEntity {Sid=2,Name="Keerthis", Gender="Female" , Email="Keerthis@gmail.com" },
- new EmployeeEntity {Sid=3,Name="Divyap", Gender="Female" , Email="Divyap@gmail.com" },
- };
- }
- public List<Student> getEmployeeFromDb()
- {
- StudentEntityModel Db = new StudentEntityModel();
- return Db.Student.ToList();
- }
- }
Add Comment
Please, Sign In to add comment