示例#1
0
        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());
        }
示例#2
0
        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);
        }
示例#3
0
        public RequestResult <object> InsUpd(AlertModel model)
        {
            AlertDA alertDA = new AlertDA();

            return(alertDA.InsUpd(model));
        }