public bool AddMethodOfPaymentToHairSalon(int idHairSalon, MethodOfPayment addMethodOfPayment)
        {
            MethodOfPayment methodOfPayment = unitOfWork.MethodsOfPayment.Get(addMethodOfPayment.Id);

            HairSalonMethodsOfPayment newHairSalonMethodsOfPayment = new HairSalonMethodsOfPayment()
            {
                HairSalonId     = idHairSalon,
                MethodOfPayment = methodOfPayment
            };

            IEnumerable <HairSalonMethodsOfPayment> hairSalonMethodsOfPayment = unitOfWork.HairSalonMethodsOfPayment.GetHairSalonMethodsOfPayments(idHairSalon);

            foreach (HairSalonMethodsOfPayment hairSalonMethodOfPayment in hairSalonMethodsOfPayment)
            {
                if (hairSalonMethodOfPayment.MethodOfPaymentId == methodOfPayment.Id)
                {
                    return(false);
                }
            }

            unitOfWork.HairSalonMethodsOfPayment.Add(newHairSalonMethodsOfPayment);

            int success = unitOfWork.Complete();

            return(success > 0);
        }
        public bool RemoveHairSalonMethodOfPayment(int id)
        {
            HairSalonMethodsOfPayment hairSalonMethodsOfPayment = unitOfWork.HairSalonMethodsOfPayment.Get(id);

            unitOfWork.HairSalonMethodsOfPayment.Remove(hairSalonMethodsOfPayment);

            int success = unitOfWork.Complete();

            return(success > 0);
        }
Exemple #3
0
        public async Task<bool> RemoveHairSalonMethodOfPayment(HairSalonMethodsOfPayment hairSalonMethodsOfPayment)
        {
            HttpClient request = new HttpClient();
            request.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(HEAD));

            HttpResponseMessage response = await request.DeleteAsync($"{ API_URL }/RemoveHairSalonMethodOfPayment/{ hairSalonMethodsOfPayment.Id }");

            if (response.IsSuccessStatusCode)
            {
                bool result = await response.Content.ReadAsAsync<bool>();
                return result;
            }
            return false;
        }