public DTOs.Customer Update(int id, DTOs.Customer customer)
        {
            Customer existingCustomer = Get(id);

            existingCustomer.FirstName = customer.FirstName ?? existingCustomer.FirstName;
            existingCustomer.LastName  = customer.LastName ?? existingCustomer.LastName;
            existingCustomer.Username  = customer.Username ?? existingCustomer.Username;
            existingCustomer.Password  = customer.Password ?? existingCustomer.Password;
            existingCustomer.Email     = customer.Email ?? existingCustomer.Email;

            if (customer.BirthDate != null)
            {
                existingCustomer.BirthDate = customer.BirthDate;
            }

            if (customer.Region != null)
            {
                existingCustomer.Region = _decodesQueryProcessor.Get <RegionDecode>(customer.Region);
            }

            if (customer.FreezeDate != null)
            {
                existingCustomer.FreezeDate = customer.FreezeDate;
            }

            Update(id, existingCustomer);

            return(new DTOs.Customer().Initialize(existingCustomer));
        }
Exemple #2
0
        public override Participant Initialize(Domain.Participant domain)
        {
            Id       = domain.Id;
            Customer = new DTOs.Customer().Initialize(domain.Customer);
            Date     = domain.Date;
            Order    = new DTOs.Order().Initialize(domain.Order);
            Status   = domain.Status.Id;

            return(this);
        }
Exemple #3
0
        public override Order Initialize(Domain.Order domain)
        {
            Id            = domain.Id;
            StartDate     = DateUtils.ConvertToJavaScript(domain.StartDate);
            Owner         = new DTOs.Customer().Initialize(domain.Owner);
            PlayersNumber = domain.PlayersNumber;
            Status        = domain.Status.Id;
            Field         = new DTOs.Field().Initialize(domain.Field);

            return(this);
        }
Exemple #4
0
        public override Review Initialize(Domain.Review domain)
        {
            Id               = domain.Id;
            Title            = domain.Title;
            Description      = domain.Description;
            Date             = domain.Date;
            Reviewer         = new DTOs.Customer().Initialize(domain.Reviewer);
            ReviewedCustomer = new DTOs.Customer().Initialize(domain.ReviewedCustomer);;

            return(this);
        }
Exemple #5
0
        public override Complaint Initialize(Domain.Complaint domain)
        {
            Id                = domain.Id;
            Description       = domain.Description;
            Type              = domain.Type.Id;
            Date              = domain.Date;
            OffendingCustomer = new DTOs.Customer().Initialize(domain.OffendingCustomer);
            OffendedCustomer  = new DTOs.Customer().Initialize(domain.OffendedCustomer);

            return(this);
        }
Exemple #6
0
 public static Models.Customer CreateFrom(DTOs.Customer customer)
 {
     return(new Models.Customer()
     {
         Id = customer.Id,
         Name = customer.Name,
         GenderId = customer.Gender.Id,
         HouseNumber = customer.HouseNumber,
         AddressLine1 = customer.AddressLine1,
         State = customer.State,
         CountryId = customer.Country.Id,
         CategoryId = customer.Category.Id,
         DateOfBirth = customer.DateOfBirth,
         User = "******"
     });
 }
Exemple #7
0
        public RegistrationReponse Registration(DTOs.Customer customer)
        {
            if (_customersQueryProcessor.Exists(customer.Username))
            {
                return(new RegistrationReponse
                {
                    AlreadyExists = true
                });
            }

            _customersQueryProcessor.Save(customer);

            return(new RegistrationReponse()
            {
                AlreadyExists = false
            });
        }
        public IEnumerable <OffendingCustomersReport> GetOffendingCustomersReport(DateTime?fromDate, DateTime?untilDate, int?complaintType)
        {
            var complaintsGrouping = _complaintsQueryProcessor.Search(null, fromDate, untilDate, complaintType).GroupBy(x => x.OffendingCustomer.Id, x => x.OffendedCustomer.Id);
            List <OffendingCustomersReport> offendingList = new List <OffendingCustomersReport>();

            foreach (var item in complaintsGrouping)
            {
                DTOs.Customer customer = _customersQueryProcessor.GetCustomer(item.Key ?? 0);
                offendingList.Add(new OffendingCustomersReport()
                {
                    CustomerId         = customer.Id ?? 0,
                    FirstName          = customer.FirstName,
                    LastName           = customer.LastName,
                    NumberOfComplaints = item.Count()
                });
            }
            return(offendingList);
        }
        public DTOs.Customer Save(DTOs.Customer customer)
        {
            Customer newCustomer = new Customer
            {
                FirstName  = customer.FirstName,
                LastName   = customer.LastName,
                Username   = customer.Username,
                Password   = customer.Password,
                BirthDate  = customer.BirthDate,
                Email      = customer.Email,
                Region     = _decodesQueryProcessor.Get <RegionDecode>(customer.Region),
                FreezeDate = customer.FreezeDate
            };

            Customer persistedCustomer = Save(newCustomer);

            return(new DTOs.Customer().Initialize(persistedCustomer));
        }
Exemple #10
0
        public DTOs.CustomerUpdateResponse Update(int id, [FromBody] DTOs.Customer customer)
        {
            string authenticationKey = null;

            var currPrincipal = HttpContext.Current.User as ClaimsPrincipal;
            var currIdentity  = currPrincipal.Identity as BasicAuthenticationIdentity;

            if (currIdentity.Claims.Contains(new Claim(ClaimTypes.Role, Consts.Roles.Customer), _userTypeComparer))
            {
                byte[] toEncodeAsBytes = ASCIIEncoding.ASCII.GetBytes(customer.Username + ":" + customer.Password);
                authenticationKey = "Basic " + Convert.ToBase64String(toEncodeAsBytes);
            }

            return(new DTOs.CustomerUpdateResponse
            {
                Customer = _customersQueryProcessor.Update(id, customer),
                AuthenticationKey = authenticationKey
            });
        }
Exemple #11
0
 public DTOs.Customer Save([FromBody] DTOs.Customer customer)
 {
     return(_customersQueryProcessor.Save(customer));
 }