コード例 #1
0
        public bool Register(CustomerDetails obj)
        {
            bool status = false;

            try
            {
                PackXpreZ.DataAccessLayer.Models.CustomerDetails CustObj = new PackXpreZ.DataAccessLayer.Models.CustomerDetails();
                CustObj.EmailId      = obj.EmailId;
                CustObj.CustomerName = obj.CustomerName;
                CustObj.Password     = obj.Password;
                CustObj.ContactNo    = obj.ContactNo;
                status = repos.RegisterUser(CustObj);
                PackXpreZ.DataAccessLayer.Models.Address addObj = new PackXpreZ.DataAccessLayer.Models.Address();
                addObj.EmailId    = obj.EmailId;
                addObj.BuildingNo = obj.BuildingNo;
                addObj.StreetName = obj.StreetName;
                addObj.Locality   = obj.Locality;
                addObj.Pincode    = obj.Pincode;
                status            = repos.AddAddress(addObj);
            }
            catch (Exception)
            {
                status = false;
            }
            return(status);
        }
コード例 #2
0
        public IActionResult CreateAddress(Address newAddress, string custId)
        {
            if (!ModelState.IsValid)
            {
                _eventLogger.LogInformation("Failed: Failed to add address");
                return(BadRequest(ModelState));
            }
            else
            {
                var addressToAdd = new Address {
                    StreetName = newAddress.StreetName, Number = newAddress.Number, PostalCode = newAddress.PostalCode, Area = newAddress.Area
                };

                customerRepository.AddAddress(addressToAdd, int.Parse(custId), databaseContext);

                _eventLogger.LogInformation("Command: Added address");
                return(Ok($"Added {addressToAdd.StreetName} {addressToAdd.Number}."));
            }
        }