Esempio n. 1
0
        public long GetMaxReportRightsId()
        {
            POS_REPORT_RIGHTS entity = new POS_REPORT_RIGHTS();
            long id = 0;

            try
            {
                entity = _objEntityModel.POS_REPORT_RIGHTS.OrderByDescending(x => x.REPORT_RIGHTS_ID).FirstOrDefault();
                if (entity == null)
                {
                    id = 1;
                }
                else
                {
                    id = entity.REPORT_RIGHTS_ID + 1;
                }

                return(id);
            }
            catch (Exception ex)
            {
                ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException();
            }
        }
Esempio n. 2
0
        public int UpdateReportRights(List <POS_REPORT_RIGHTS> lstReportRights, long userId)
        {
            int isRowsCreated = 0;

            try
            {
                foreach (var item in lstReportRights)
                {
                    if (item.Selection == true)
                    {
                        POS_REPORT_RIGHTS entity = new POS_REPORT_RIGHTS();
                        entity.REPORT_RIGHTS_ID = GetMaxReportRightsId();
                        entity.REPORT_ID        = item.REPORT_ID;
                        entity.USER_ID          = userId;
                        entity.ISPOSTED_FLAG    = false;
                        entity.CREATEDBY        = item.CREATEDBY;
                        entity.CREATEDWHEN      = item.CREATEDWHEN;

                        _objEntityModel.POS_REPORT_RIGHTS.Add(entity);
                        isRowsCreated = _objEntityModel.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                //ExceptionLogger.WriteExceptionInDB(ex, ExceptionLevel.DAL, ExceptionType.Error);
                throw new DALException(ex.Message.ToString());
            }
            return(isRowsCreated);
        }