public ActionResult Save(Profile obj, int?[] ids) { ConnectionFactory conex = null; try { List <Restriction> lst = new List <Restriction>(); foreach (var item in ids) { lst.Add(new Restriction { IdRestriction = (byte)item }); } obj.Restrictions = lst; conex = new ConnectionFactory(); ProfileDAO dao = new ProfileDAO(conex); conex.BeginTran(); if (obj.IdProfile == 0) { dao.Insert(obj); TempData["SuccessMsg"] = "Perfil salva com sucesso!"; } else { dao.Update(obj); TempData["SuccessMsg"] = "Perfil Editada com sucesso!"; } conex.Commit(); } catch (Exception ex) { conex.Rollback(); TempData["SuccessMsg"] = ""; TempData["ErrorMsg"] = String.Format("Falha ao salvar o perfil. {0}", ex.Message); return(View("Create", obj)); } return(RedirectToAction("Index")); }
public void UpdateProfile( string PhoneNumber, string Name, int IDNumber) { BillingSystemContext context = new BillingSystemContext(); Profile profile = new Profile() { PhoneNumber = PhoneNumber, Name = Name, IDNumber = IDNumber }; ProfileDAO dao = new ProfileDAO(); dao.Update(profile); }
public virtual OperationResult Update(Profile profile) { try { using var transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOptions, TransactionScopeAsyncFlowOption.Enabled); _dao.Update(profile); transactionScope.Complete(); return(new OperationResult <List <Profile> >() { Success = true }); } catch (Exception e) { return(new OperationResult <List <Profile> >() { Success = false, Exception = e }); } }