예제 #1
0
 public HttpResponseMessage Delete(int id)
 {
     try
     {
         using (AngularWebAPIEntities entities = new AngularWebAPIEntities())
         {
             var entity = entities.CORUSERMSTs.FirstOrDefault(e => e.User_ID == id);
             if (entity == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                    "Employee with Id = " + id.ToString() + " not found to delete"));
             }
             else
             {
                 entities.CORUSERMSTs.Remove(entity);
                 entities.SaveChanges();
                 return(Request.CreateResponse(HttpStatusCode.OK));
             }
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
     }
 }
예제 #2
0
        public HttpResponseMessage Put(int id, [FromBody] CORUSERMST user)
        {
            try
            {
                using (AngularWebAPIEntities entities = new AngularWebAPIEntities())
                {
                    var entity = entities.CORUSERMSTs.FirstOrDefault(e => e.User_ID == id);
                    if (entity == null)
                    {
                        return(Request.CreateErrorResponse(HttpStatusCode.NotFound,
                                                           "Employee with Id " + id.ToString() + " not found to update"));
                    }
                    else
                    {
                        entity.User_Address  = user.User_Address;
                        entity.User_EmailID  = user.User_EmailID;
                        entity.User_Name     = user.User_Name;
                        entity.User_Password = user.User_Password;
                        entity.User_Username = user.User_Username;


                        entities.SaveChanges();

                        return(Request.CreateResponse(HttpStatusCode.OK, entity));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
예제 #3
0
 public void Post([FromBody] CORUSERMST user)
 {
     using (AngularWebAPIEntities entities = new AngularWebAPIEntities())
     {
         entities.CORUSERMSTs.Add(user);
         entities.SaveChanges();
     }
 }