public UserAuth GenerateToken(int UserId, string Password) { string token = Guid.NewGuid().ToString(); //DateTime issuedOn = DateTime.Now; DateTime expiredOn = DateTime.Now.AddSeconds(1000000); var tokendomain = new UserAuth { UserId = UserId, Password = Password, AuthToken = token, ExpiryTime = expiredOn }; UserAuth ua = new UserAuth(); BasicsEntities sd = new BasicsEntities(); ua = sd.UserAuths.Where(x => x.UserId == UserId & x.Password == Password).FirstOrDefault(); if (ua.UserId != null) { ua.AuthToken = tokendomain.AuthToken; //ua.IssuedOn = tokendomain.IssuedOn; ua.ExpiryTime = tokendomain.ExpiryTime; sd.SaveChanges(); } return(tokendomain); }
public IHttpActionResult DeleteEmployee(int Id) { BasicsEntities Db = new BasicsEntities(); var del = (from Item in Db.Employees where Item.Id == Id select Item).FirstOrDefault(); Db.Employees.Remove(del); //var EmpList = Db.Employees.Where(e => e.Id == Id).FirstOrDefault(); //Db.Entry(employee).State = System.Data.Entity.EntityState.Deleted; Db.SaveChanges(); return(Ok("Delete successfull!!")); }
public IHttpActionResult PutEmployee(Employee employee) { BasicsEntities Db = new BasicsEntities(); var EmpList = Db.Employees.Where(e => e.Id == employee.Id).FirstOrDefault(); EmpList.Name = employee.Name; EmpList.Email = employee.Email; EmpList.Phone = employee.Phone; Db.SaveChanges(); return(Ok("Put successfull!!")); }
public IHttpActionResult PostEmployee(Employee employee) { BasicsEntities Db = new BasicsEntities(); Db.Employees.Add(new Employee() { Name = employee.Name, Email = employee.Email, Phone = employee.Phone }); Db.SaveChanges(); return(Ok("Post successfull!!")); }