public AlertModel MarkAsReaded(AlertModel model) { //Se marca como leída model.Status = (int)AlertStatus.Readed; AlertDA alertDA = new AlertDA(); var resp = alertDA.InsUpd(model); if (resp != null) { throw new Exception(resp.Message); } //Retornamos la última alerta, nos servirá para sustituir la que eliminamos en la UI PagerModel pager = new PagerModel(7, 1, "CreatedAt", "desc"); AlertModel filter = new AlertModel(); filter.Status = (int)AlertStatus.New; filter.To = model.To; return(Get(pager, filter).FirstOrDefault()); }
public RequestResult <object> InsUpd(List <AlertModel> lst) { RequestResult <object> resp = new RequestResult <object>(); AlertDA alertDA = new AlertDA(); TransactionOptions scopeOptions = new TransactionOptions(); scopeOptions.IsolationLevel = IsolationLevel.Serializable; using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required, scopeOptions)) { try { foreach (AlertModel model in lst) { resp = alertDA.InsUpd(model); if (resp != null && resp.Status == Status.Error) { throw new Exception(resp.Message); } } ts.Complete(); } catch (Exception ex) { ts.Dispose(); resp = new RequestResult <object>() { Status = Status.Error, Message = ex.Message }; Elmah.ErrorSignal.FromCurrentContext().Raise(ex); throw ex; } } return(resp); }
public List <AlertModel> Get(PagerModel pager, AlertModel filter) { AlertDA alertDA = new AlertDA(); return(alertDA.Get(pager, filter)); }
public RequestResult <object> InsUpd(AlertModel model) { AlertDA alertDA = new AlertDA(); return(alertDA.InsUpd(model)); }