Ejemplo n.º 1
0
        public MyServiceItem(Service service)
        {
            if (service == null)
                throw new ArgumentException("service cannot be null or whitespace");

            _serviceId = service.Id;

            Bid lowestBid = service.Bids
            .Where(o => !o.IsCancelled)
            .OrderBy(o => o.Amount)
            .FirstOrDefault();

            _lowestBid = lowestBid == null ? 0 : lowestBid.Amount;
            _reference = service.Reference;
            _isCompleted = false;

            if (service.IsCancelled)
            {
                _isCompleted = true;
                _status = "Cancelled";
            }
            else if (service.AcceptedBid != null && !service.AcceptedBid.IsCancelled)
            {
                _isCompleted = true;
                _status = "Accepted";
            }
            else if (service.BiddingCompletionDate < DateTime.Now)
                _status = "Bidding Completed";
            else
                _status = "Bidding In Progress";

            _estimatedServiceDue = service.ServiceDue;
            _biddingCompletion = service.BiddingCompletionDate;
        }
Ejemplo n.º 2
0
        public MyBidItem(Service service, Guid userId)
        {
            if (service == null)
                throw new ArgumentException("service cannot be null or whitespace");

            _serviceId = service.Id;
            _highestBid = service
                .LatestBids()
                .Max(o => o.Amount);

            _myHighestBid = service.LatestBidForUser(userId).Amount;

            _reference = service.Reference;
            _isCompleted = service.BiddingCompletionDate<DateTime.Now;

            if (service.AcceptedBid!=null && !service.AcceptedBid.IsCancelled)
            {
                if (service.AcceptedBid.Bid.UserId == userId)
                    _status = "Successful";
                else
                    _status = "Unsuccessful";
            }
            else
                _status = "To be accepted!";

            _estimatedServiceDue = service.ServiceDue;
            _biddingCompletion = service.BiddingCompletionDate;
        }
        public BidAcceptanceViewModel(Service service)
        {
            _serviceViewModel = new ServiceViewModel(service);

            if (service != null)
            {

                FinalServiceProviderBidViewModels = service
                .LatestBids().Select(o => new FinalServiceProviderBidViewModel(o)).ToList();
            }
            else
                FinalServiceProviderBidViewModels = new List<FinalServiceProviderBidViewModel>();
        }
Ejemplo n.º 4
0
        public void PostService(Models.PostServiceViewModel postServiceViewModel)
        {
            User user = _serviceHubEntities.Users.SingleOrDefault(o => o.AspNetUserId == _aspNetUserId);
            Tag tag = _serviceHubEntities.Tags.SingleOrDefault(o => o.Id == postServiceViewModel.ServiceTagId);
            Location location = _serviceHubEntities.Locations.SingleOrDefault(o => o.Id == postServiceViewModel.LocationId);

            Service service = new Service();
            service.Description = postServiceViewModel.Description;
            service.User = user;
            service.BiddingCompletionDate = GetEndOfDay(postServiceViewModel.BiddingCompletionDate.Value);
            service.ServiceDue = GetEndOfDay(postServiceViewModel.ServiceDate.Value);
            service.Tag = tag;
            service.Location = location;
            service.TimeStamp = DateTime.Now;
            service.IsCancelled = false;
            postServiceViewModel.Reference = service.Reference = string.Format(CultureInfo.InvariantCulture, "S{0}", DateTime.Now.Ticks);

            _serviceHubEntities.Services.Add(service);
        }
Ejemplo n.º 5
0
        public ServiceViewModel(Service service)
        {
            if (service != null)
            {
                _serviceId = service.Id;

                _biddingCompletionDate = service.BiddingCompletionDate;
                _description = service.Description;
                _location = service.Location.Name;
                _reference = service.Reference;
                _serviceDate = service.ServiceDue;
                _serviceTag = service.Tag.Title;
                _addtionalInfo = service.AdditionalInfos.Select(o => o.Comment).ToList();
                _addtionalInfoRequests = service.AdditionalInfoRequests.Select(o => o.Comment).ToList();
                _isCancelled = service.IsCancelled;
            }
            else
            {
                _addtionalInfo = new List<string>();
                _addtionalInfoRequests = new List<string>();
            }
        }