public HttpResponseMessage UpdateUsertypes(ApiModels.MstUserType objUsertypes, String Id) { try { var usertype = from d in db.MstUserTypes where d.Id == Convert.ToInt32(Id) select d; if (usertype.Any()) { var updateUsertypes = usertype.FirstOrDefault(); updateUsertypes.Id = objUsertypes.Id; updateUsertypes.UserType = objUsertypes.UserType; db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } else { return(Request.CreateResponse(HttpStatusCode.BadRequest, "UserType not found!")); } } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message)); } }
public HttpResponseMessage AddUsertypes(ApiModels.MstUserType objUsertypes) { try { Data.MstUserType newUsertype = new Data.MstUserType { Id = objUsertypes.Id, UserType = objUsertypes.UserType }; db.MstUserTypes.InsertOnSubmit(newUsertype); db.SubmitChanges(); return(Request.CreateResponse(HttpStatusCode.OK)); } catch (Exception e) { return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message)); } }