public static int CreateClientRepresentatives(ClientRepresentatives clientRepresentative) { try { using (VedantaEntities ve = new VedantaEntities()) { ve.AddToClientRepresentatives(clientRepresentative); return(ve.SaveChanges()); } } catch (Exception) { return(0); } }
public ActionResult CreateRepresentative(int id, FormCollection form, ClientRepresentatives clientRepresentative) { try { if (!ModelState.IsValid) { return(View()); } // TODO: Add insert logic here if (id > 0) { clientRepresentative.ClientId = id; bool isActive = false; if (!string.IsNullOrEmpty(form["rdoYes"])) { bool.TryParse(form["rdoYes"], out isActive); } clientRepresentative.IsActive = isActive; if (ClientModels.CreateClientRepresentatives(clientRepresentative) > 0) { return(RedirectToAction("RepresentativeList", new { @id = id })); } } else { return(View()); } } catch { return(View()); } return(View()); }