Example #1
0
        public SystemConstantResponse GetSystemConstantList(SystemConstantRequest request)
        {
            SystemConstantResponse response = new SystemConstantResponse();
            using (var context = new hamptondwellEntities())
            {
                var SystemConstant = (from a in context.SystemConstants.
                                   Where(
                                       a =>
                                       a.Active == request.Active &&
                                       (string.IsNullOrEmpty(request.FirstLetter) ||
                                        a.Name.StartsWith(request.FirstLetter)))
                                      select a);

                SystemConstant = GetListSort(SystemConstant, request);

                SystemConstant = SystemConstant.Skip(request.StartRowIndex).Take(request.MaximumRows);
                response.SystemConstantList = SystemConstant.Select(a => new SystemConstantObject
                {
                    SystemConstantId = a.SystemConstantID,
                    Name = a.Name,
                    ConstantValue = a.ConstantValue,
                    CreatedBy = (a.User1 != null ? a.User1.Email : string.Empty),
                    Active = a.Active,
                    ModifiedBy = (a.User != null ? a.User.Email : string.Empty),
                    ModifiedByUserId = a.ModifiedBy_UserID,
                    CreatedByUserId = a.CreatedBy_UserID,
                    ModifiedOn = a.ModifiedOn,
                    CreatedOn = a.CreatedOn
                }).ToList();
                response.ResultSetCount = GetSystemConstantListCount(request);
            }
            return response;
        }
        public static SystemConstantResponse GetSystemConstantByName(SystemConstantRequest request)
        {
            SystemConstantResponse response = new SystemConstantResponse();
            using (var context = new hamptondwellEntities())
            {
                var systemConstant = context.SystemConstants.
                    Where(u => u.Active == true && u.Name == request.Name).FirstOrDefault();
                if (systemConstant != null)
                {
                    response.SystemConstant = new SystemConstantObject()
                    {
                        SystemConstantId = systemConstant.SystemConstantID,
                        Active = systemConstant.Active,
                        ConstantValue = systemConstant.ConstantValue,
                        CreatedByUserId = systemConstant.CreatedBy_UserID,
                        ModifiedByUserId = systemConstant.ModifiedBy_UserID,
                        Name = systemConstant.Name,
                        ModifiedOn = systemConstant.ModifiedOn,
                        CreatedOn = systemConstant.CreatedOn
                    };

                }
                response.SystemConstant = response.SystemConstant ?? new SystemConstantObject();
            }
            return response;
        }
Example #3
0
        public SystemConstantResponse SaveSystemConstantByName(SystemConstantRequest request)
        {
            SystemConstantResponse response = new SystemConstantResponse();
            using (var context = new hamptondwellEntities())
            {
                var systemConstant = context.SystemConstants.
                    Where(u => u.Active == true && u.Name == request.Name).FirstOrDefault();

                systemConstant = systemConstant ?? new SystemConstant();

                systemConstant.ConstantValue = request.ConstantValue;
                systemConstant.ModifiedBy_UserID = request.ModifiedByUserId;
                systemConstant.ModifiedOn = DateTime.UtcNow;

                context.SaveChanges();

                response.SystemConstant = new SystemConstantObject()
                {
                    SystemConstantId = systemConstant.SystemConstantID,
                    Active = systemConstant.Active,
                    ConstantValue = systemConstant.ConstantValue,
                    CreatedByUserId = systemConstant.CreatedBy_UserID,
                    Name = systemConstant.Name,
                    CreatedOn = systemConstant.CreatedOn,
                    ModifiedByUserId = systemConstant.ModifiedBy_UserID,
                    ModifiedOn = systemConstant.ModifiedOn
                }
                ;
            }
            return response;
        }