public async Task <IHttpActionResult> Post(user user) { if (ModelState.IsValid) { try { user modiUser = await Repo.GetEntity(user.Id); if (modiUser != null)// for update { Repo.Update(user); } else { Repo.Add(user);// for new user UOW.Save(); } return(Ok()); } catch { return(BadRequest()); } } else { return(BadRequest()); } }
public IHttpActionResult Post(role_user_id obj) { if (ModelState.IsValid) { try { int id = int.Parse(obj.roleid); Repo.Add(new usersrole() { UserId = obj.userid, Roleid = id }); // for new user UOW.Save(); return(Ok()); } catch { return(BadRequest()); } } else { return(BadRequest()); } }
//in case create new task // or update task by manager to assign it to group public async Task <IHttpActionResult> Post(request req) { if (ModelState.IsValid) { try { request modireq = await Repo.GetEntity(req.Id); if (modireq != null)//for update { Repo.Update(req); } else { Repo.Add(new request() { requestTitle = req.requestTitle, requestBody = req.requestBody }); //for new UOW.Save(); } return(Ok(new request())); } catch (Exception e) { return(BadRequest()); } } else { return(BadRequest()); } }
public ActionResult Create(Model collection) { try { if (ModelState.IsValid) { Repositry.Add(collection); Repositry.SaveAll(); return(Ok("The Model has been Created")); } return(BadRequest("The Model is Not Valid")); } catch { return(BadRequest("An Error Has Occurred.")); } }