コード例 #1
0
        /// <summary>
        /// This method gets Locker by id
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public async Task <LockerDVM> GetLockerByID(object Id)
        {
            LockerDVM cdvm = null;

            if (Id != null)
            {
                Locker c = await lockerRepository.GetAsync(Id);

                if (c != null)
                {
                    cdvm = mapper.Map <LockerDVM>(c);
                }
            }
            return(cdvm);
        }
コード例 #2
0
        /// <summary>
        /// This method Adds a new Locker and returns the id
        /// </summary>
        /// <param name="Locker"></param>
        /// <returns></returns>
        public async Task <int> AddLocker(LockerDVM Locker)
        {
            int id = 0;

            if (Locker != null)
            {
                Locker c = mapper.Map <Locker>(Locker);
                try
                {
                    var obj = await lockerRepository.InsertAsync(c);

                    id = obj.LockerId;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(id);
        }
コード例 #3
0
        /// <summary>
        /// This method updates a Locker and returns true if successful
        /// </summary>
        /// <param name="Locker"></param>
        /// <returns></returns>
        public async Task <bool> UpdateLocker(LockerDVM Locker)
        {
            bool result = false;

            if (Locker != null)
            {
                Locker c = await lockerRepository.GetAsync(Locker.LockerId);

                if (c != null)
                {
                    c.Name              = Locker.Name;
                    c.CityId            = Locker.CityId;
                    c.Description       = Locker.Description;
                    c.Price             = Locker.Price;
                    c.QuantityAvailable = Locker.QuantityAvailable;
                    c.StateCode         = Locker.StateCode;
                    c.DateCreated       = Locker.DateCreated;
                    c.DateModified      = Locker.DateModified;
                    c.ModifiedBy        = Locker.ModifiedBy;
                    c.DateModified      = Locker.DateModified;
                    c.Status            = Locker.Status;
                    c.Size              = Locker.Size;
                    c.ImageUrl          = Locker.ImageUrl;
                    try
                    {
                        await lockerRepository.UpdateAsync(c);

                        result = true;
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
            return(result);
        }