public string Edit(TransactionDomainModel ts) { if ((Convert.ToInt32(ts.AccountID) == 0) || (Convert.ToInt32(ts.Amount) == 0) || (Convert.ToInt32(ts.TransactionType) == 0) || (ts.Date == Convert.ToDateTime("01-01-0001"))) { return("One or more fields are empty"); } else { trans_type t_type = tRep.SingleOrDefault(x => x.ID == ts.TransactionType); transaction trans = tsRep.SingleOrDefault(x => x.ID == ts.ID); if (ts.AccountID == ts.AccountTransferTo) { return("You cant transfer from and to one account"); } if (t_type.Description != "Transfer" && ts.AccountTransferTo != null) { return("Speciefied operation is not transfer, so it can't have 'transfer to' field"); } trans.AccountID = ts.AccountID; trans.Amount = Convert.ToDouble(ts.Amount); trans.TransactionType = ts.TransactionType; if (t_type.Description == "Transfer" && ts.AccountTransferTo == null) { return("No destination account of the transfer was specified"); } trans.AccountTransferTo = ts.AccountTransferTo; trans.Date = ts.Date; tsRep.Update(trans); return(""); } }
public ActionResult EditType(int ID) { trans_type trans = t.GetType(ID); TypeViewModel trans_vm = new TypeViewModel(); var mapper_trans = new MapperConfiguration(cfg => cfg.CreateMap <trans_type, TypeViewModel>()).CreateMapper(); var type = mapper_trans.Map <trans_type, TypeViewModel>(trans); List <string> list = new List <string>(); list.Add("transfer"); list.Add("outcome"); list.Add("income"); ViewBag.Types = new SelectList(list); return(View(type)); }
public string EditType(TypeDomainModel DM) { if ((DM.Description == null) || (DM.Type == null)) { return("One or more fields are empty"); } else { trans_type t = tRep.SingleOrDefault(x => x.ID == DM.ID); t.Description = DM.Description; t.Type = DM.Type; tRep.Update(t); return(""); } }
public string AddType(TypeDomainModel DM) { if ((DM.Description == null) || (DM.Type == null)) { return("One or more fields are empty"); } else { trans_type t = new trans_type(); t.Description = DM.Description; t.Type = DM.Type; tRep.Insert(t); return(""); } }
public trans_type GetType(int ID) { trans_type trans = tRep.SingleOrDefault(x => x.ID == ID); return(trans); }