public ActionResult GetById(int id)
        {
            int          iCode    = 200;
            BaseResponse response = null;

            try
            {
                ProviderLicense license = _service.Get(id);

                if (license == null)
                {
                    iCode    = 404;
                    response = new ErrorResponse("Application resource not found");
                }
                else
                {
                    response = new ItemResponse <ProviderLicense> {
                        Item = license
                    };
                }
            }
            catch (Exception ex)
            {
                iCode = 500;

                base.Logger.LogError(ex.ToString());
                response = new ErrorResponse(ex.Message);
            }

            return(StatusCode(iCode, response));
        }
Ejemplo n.º 2
0
        public Paged <ProviderLicense> GetByCreatedBy(int pageIndex, int pageSize, int createdBy)
        {
            string procName = "dbo.Licenses_Select_ByCreatedBy";
            Paged <ProviderLicense> pagedList = null;
            List <ProviderLicense>  list      = null;
            int totalCount = 0;

            _data.ExecuteCmd(procName, inputParamMapper : delegate(SqlParameterCollection param){
                param.AddWithValue("@CurrentPage", pageIndex);
                param.AddWithValue("@ItemsPerPage", pageSize);
                param.AddWithValue("@CreatedBy", createdBy);
            }, singleRecordMapper : delegate(IDataReader reader, short set) {
                int startingIndex  = 0;
                ProviderLicense pl = MapLicense(reader, out startingIndex);
                if (list == null)
                {
                    totalCount = reader.GetSafeInt32(startingIndex += 1);
                    list       = new List <ProviderLicense>();
                }
                list.Add(pl);
            });
            if (list != null)
            {
                pagedList = new Paged <ProviderLicense>(list, pageIndex, pageSize, totalCount);
            }
            return(pagedList);
        }
Ejemplo n.º 3
0
        private static ProviderLicense MapLicense(IDataReader reader, out int index)
        {
            index = 0;
            ProviderLicense license = new ProviderLicense();

            license.Id = reader.GetSafeInt32(index);


            license.LicenseNumber = reader.GetSafeString(index += 1);
            license.DateExpires   = reader.GetSafeDateTime(index += 1);
            license.CreatedBy     = reader.GetSafeInt32(index += 1);
            license.DateCreated   = reader.GetSafeDateTime(index += 1);
            license.ModifiedBy    = reader.GetSafeInt32(index += 1);
            license.DateModified  = reader.GetSafeDateTime(index += 1);

            int      userProfileId = reader.GetSafeInt32(index += 1);
            int      userId        = reader.GetSafeInt32(index += 1);
            string   firstName     = reader.GetSafeString(index += 1);
            string   lastName      = reader.GetSafeString(index += 1);
            string   mi            = reader.GetSafeString(index += 1);
            string   avatarUrl     = reader.GetSafeString(index += 1);
            DateTime dateCreated   = reader.GetSafeDateTime(index += 1);
            DateTime dateModified  = reader.GetSafeDateTime(index += 1);
            int      createdBy     = reader.GetSafeInt32(index += 1);
            int      modifiedBy    = reader.GetSafeInt32(index += 1);
            int      stateId       = reader.GetSafeInt32(index += 1);
            string   state         = reader.GetSafeString(index += 1);

            string stateCode = reader.GetSafeString(index += 1);

            if (userProfileId > 0)
            {
                license.UserProfile              = new UserProfile();
                license.UserProfile.Id           = userProfileId;
                license.UserProfile.UserId       = userId;
                license.UserProfile.FirstName    = firstName;
                license.UserProfile.LastName     = lastName;
                license.UserProfile.Mi           = mi;
                license.UserProfile.AvatarUrl    = avatarUrl;
                license.UserProfile.DateCreated  = dateCreated;
                license.UserProfile.DateModified = dateModified;
                license.UserProfile.CreatedBy    = createdBy;
                license.UserProfile.ModifiedBy   = modifiedBy;
            }
            if (stateId > 0)
            {
                license.State      = new State();
                license.State.Id   = stateId;
                license.State.Name = state;
                license.State.Code = stateCode;
            }
            return(license);
        }
Ejemplo n.º 4
0
        public ProviderLicense Get(int id)
        {
            string          procName = "dbo.Licenses_Select_ById";
            ProviderLicense license  = null;

            _data.ExecuteCmd(procName, inputParamMapper : delegate(SqlParameterCollection parameterCollection)
            {
                parameterCollection.AddWithValue("@Id", id);
            }, singleRecordMapper : delegate(IDataReader reader, short set)
            {
                int startingIndex = 0;
                license           = MapLicense(reader, out startingIndex);
            });
            return(license);
        }