Пример #1
0
        public async Task <Response> NotifyBidSuppliers(string bidId, string body, string subject)
        {
            IEnumerable <KeyValuePair <string, string> > emailNamePairs;

            try
            {
                emailNamePairs = await _context.Set <SupplierProposalEntity>()
                                 .Where(p => p.BidId == bidId).Include(p => p.Supplier).Select(p => new KeyValuePair <string, string>(p.Supplier.Email, p.Supplier.Name)).ToListAsync().ConfigureAwait(false);

                // Console.WriteLine("NotifyBidSuppliers");
                // Console.WriteLine(string.Join(", ", emailNamePairs.Select(p => p.ToString())));
            }
            catch (Exception ex)
            {
                return(new Response()
                {
                    IsOperationSucceeded = false, SuccessOrFailureMessage = ex.Message
                });
            }
            return(await NotifyList(body, subject, emailNamePairs, bidId));
        }
Пример #2
0
        public async Task <Response> DeleteBuyer(string bidId, string buyerId)
        {
            BidEntity bid = await _context.Bids.Where(b => b.Id == bidId).Include(b => b.CurrentParticipancies).FirstOrDefaultAsync().ConfigureAwait(false);

            if (bid == null)
            {
                return(new Response()
                {
                    IsOperationSucceeded = false, SuccessOrFailureMessage = BidNotFoundFailString
                });
            }
            ParticipancyEntity participancy = bid.CurrentParticipancies.Find(p => p.BuyerId == buyerId);

            if (participancy == null)
            {
                return(new Response()
                {
                    IsOperationSucceeded = false, SuccessOrFailureMessage = ParticipantNotFoundFailString
                });
            }
            bid.UnitsCounter -= participancy.NumOfUnits;
            bid.CurrentParticipancies.Remove(participancy);
            _context.Set <ParticipancyEntity>().Remove(participancy);
            try
            {
                _context.Bids.Update(bid);
                await _context.SaveChangesAsync().ConfigureAwait(false);
            }
            catch (Exception ex)
            {
                return(new Response()
                {
                    IsOperationSucceeded = false, SuccessOrFailureMessage = ex.Message
                });
            }
            return(new Response()
            {
                IsOperationSucceeded = true, SuccessOrFailureMessage = this.getSuccessMessage()
            });
        }
        public async Task <object> GetrecordAsync()
        {
            List <string> data;

            try
            {
                data = await _context
                       .Set <ProductEntity>()
                       .Select(product => product.Name)
                       .OrderBy(name => name)
                       .ToListAsync();
            }
            catch
            {
                data = new List <string>();
            }

            return(data);
        }