public string AddSignal(ServiceTradeSignalModel newTradeSignal) { try { using (var ctx = DatabaseContext.Instance.Make()) { var acc = ctx.ACCOUNT.Single(x => x.ID == newTradeSignal.AccountId); ctx.SERVICE.Add(new SERVICE { User = newTradeSignal.User, FixedPrice = newTradeSignal.FixedPrice, Comment = newTradeSignal.Comment, ServiceType = (short)newTradeSignal.ServiceType, Currency = acc.Currency, AccountId = acc.ID }); ctx.SaveChanges(); } } catch (Exception ex) { Logger.Error("AddSignal", ex); return(Resource.ErrorMessageTradeSignalUnableAdd); } return(string.Empty); }
public string EditSignal(ServiceTradeSignalModel oldTradeSignal) { try { using (var ctx = DatabaseContext.Instance.Make()) { var acc = ctx.ACCOUNT.Single(x => x.ID == oldTradeSignal.AccountId); var signal = ctx.SERVICE.Single(x => x.ID == oldTradeSignal.Id); signal.User = oldTradeSignal.User; signal.FixedPrice = oldTradeSignal.FixedPrice; signal.Comment = oldTradeSignal.Comment; signal.ServiceType = (short)oldTradeSignal.ServiceType; signal.Currency = acc.Currency; signal.AccountId = acc.ID; ctx.SaveChanges(); } } catch (Exception ex) { Logger.Error("AddSignal", ex); return(Resource.ErrorMessageTradeSignalUnableEdit); } return(string.Empty); }
public ActionResult AddSignal(ServiceTradeSignalModel item) { if (!ModelState.IsValid) { return(Json(new { status = false, errorString = Resource.ErrorMessageInvalid }, JsonRequestBehavior.AllowGet)); } var result = item.Id == -1 ? tradeSignalRepository.AddSignal(item) : tradeSignalRepository.EditSignal(item); return(Json(String.IsNullOrEmpty(result) ? new { status = true, errorString = result } : new { status = false, errorString = result }, JsonRequestBehavior.AllowGet)); }