/// <summary> /// If a DC has a license into a state /// </summary> /// <param name="DC"></param> /// <param name="Into"></param> /// <returns></returns> public bool AbleToShipInto(DistributionCenter DC, State Into) { string statecode = Into.StateCode; IObjectSpace objectSpace = this.application.CreateObjectSpace(typeof(DistributionCenterLicenses)); int goodcount = 0; CriteriaOperator op = CriteriaOperator.Parse("DistributionCenterId = ? AND State = ? AND LicenseTypeCode = ?", DC.Oid, statecode, "STAT"); IList DCLic = objectSpace.GetObjects(typeof(DistributionCenterLicenses), op); if (DCLic.Count > 0) { foreach (DistributionCenterLicenses dl in DCLic) { if (dl.ExpirationDate >= DateTime.Now) { goodcount++; } } } if (goodcount > 0) { return(success); } return(failed); }
public string RegisterStorage(string type, string name) { Storage storage; switch (type) { case "AutomatedWarehouse": storage = new AutomatedWarehouse(name); break; case "DistributionCenter": storage = new DistributionCenter(name); break; case "Warehouse": storage = new Warehouse(name); break; default: throw new InvalidOperationException("Invalid storage type!"); } this.storages.Add(name, storage); return($"Registered {name}"); }
public void TestDistributionCenterSendVehicleSendsVehiclesAndReturnsTheCorrectSlot() { var distributionCenter = new DistributionCenter("SmartSolutions"); var automatedDistributionCenter = new AutomatedWarehouse("SmartTech"); Assert.AreEqual(distributionCenter.SendVehicleTo(0, automatedDistributionCenter), 1, "Doesnt return the correct added slot from delivery location."); }
public void Update(DistributionCenter distributionCenter) { if (distributionCenter != null) { _repository.Entry <Sql.DistributionCenter>(distributionCenter).State = System.Data.Entity.EntityState.Modified; } }
public Storage CreateStorage(string type, string name) { Storage storage = null; if (type == "Warehouse") { storage = new Warehouse(name); } else if (type == "DistributionCenter") { storage = new DistributionCenter(name); } else if (type == "AutomatedWarehouse") { storage = new AutomatedWarehouse(name); } if (storage != null) { return(storage); } else { throw new InvalidOperationException("Invalid storage type!"); } }
public ResponseDTO AddDistributionCenter(DistributionCenterDTO distributionCenterDTO) { this.CheckForExisitngDistributionCenter(distributionCenterDTO); ResponseDTO responseDTO = new ResponseDTO(); DistributionCenter distributionCenter = new DistributionCenter(); distributionCenter.DCId = unitOfWork.DashboardRepository.NextNumberGenerator("DistributionCenter"); distributionCenterDTO.Password = EncryptionHelper.Encryptword(distributionCenterDTO.Password); DistributionCenterConvertor.ConvertToDistributionCenterEntity(ref distributionCenter, distributionCenterDTO, false); // customer.CustomerCode = unitOfWork.CustomerRepository.GetCustomerCodeIdByVLC(customerDto.VLCId); distributionCenter.DCCode = "DC" + distributionCenter.DCId.ToString(); distributionCenter.CreatedDate = DateTimeHelper.GetISTDateTime(); distributionCenter.ModifiedDate = DateTimeHelper.GetISTDateTime(); distributionCenter.CreatedBy = distributionCenter.ModifiedBy = "Admin"; // unitOfWork.VLCRepository.GetEmployeeNameByVLCId(customerDto.VLCId); distributionCenter.DateOfRegistration = DateTimeHelper.GetISTDateTime().Date; distributionCenter.IsDeleted = false; distributionCenter.Pin = OTPGenerator.GetSixDigitOTP(); distributionCenterDTO.DCId = distributionCenter.DCId; //creating Distribution Center wallet with Distribution Center AddDistributionCenterWallet(distributionCenter); DCAddress dCAddress = AddDistributionCenterAddress(distributionCenterDTO); if (dCAddress != null) { distributionCenter.DCAddresses.Add(dCAddress); } unitOfWork.DistributionCenterRepository.Add(distributionCenter); unitOfWork.SaveChanges(); responseDTO.Status = true; responseDTO.Message = String.Format("Distribution Center Successfully Created"); responseDTO.Data = DistributionCenterConvertor.ConvertToDistributionCenterDto(distributionCenter); return(responseDTO); }
public Storage CreateStorage(string type, string name) { Storage storage = null; switch (type) { case "AutomatedWarehouse": storage = new AutomatedWarehouse(name); break; case "DistributionCenter": storage = new DistributionCenter(name); break; case "Warehouse": storage = new Warehouse(name); break; default: throw new InvalidOperationException( string.Format( ExceptionMessages.InvalidType, "storage")); } return(storage); }
public string RegisterStorage(string type, string name) { Storage currentStorage; switch (type) { case "AutomatedWarehouse": currentStorage = new AutomatedWarehouse(name); break; case "DistributionCenter": currentStorage = new DistributionCenter(name); break; case "Warehouse": currentStorage = new Warehouse(name); break; default: throw new InvalidOperationException(ErrorMessage.InvalidStoradeType); } storageRegistry.Add(currentStorage); return($"Registered {name}"); }
public string RegisterStorage(string type, string name) { //Creating new newStorage variable of Storage class Storage newStorage; // if (type == "AutomatedWarehouse") //when the type is AutomatedWarehouse.. { newStorage = new AutomatedWarehouse(name); //Creating new AutomatedWarehouse with that name storages.Add(newStorage); //We add the new AutomatedWarhouse to the storages list return($"Registred {name}"); //we print out the new AutoWarehouse name that is added. } else if (type == "DistributionCenter") { newStorage = new DistributionCenter(name); storages.Add(newStorage); return($"Registred {name}"); } else if (type == "Warehouse") { newStorage = new Warehouse(name); storages.Add(newStorage); return($"Registred {name}"); } throw new NotImplementedException("Invalide storage type!"); }
public void SendVehicleToMethodWorksCorrectly() { Storage targetStorage = new DistributionCenter("TargetStorage"); int expectedSlotIndex = 3; Assert.AreEqual(expectedSlotIndex, storage.SendVehicleTo(0, targetStorage)); }
public static DistributionCenterDTO ConvertToDistributionCenterDto(DistributionCenter distributionCenter) { DistributionCenterDTO distributionCenterDTO = new DistributionCenterDTO(); distributionCenterDTO.AADHAR = distributionCenter.AADHAR; distributionCenterDTO.AgentName = distributionCenter.AgentName; distributionCenterDTO.AlternateContact = distributionCenter.AlternateContact; distributionCenterDTO.Anniversary = distributionCenter.Anniversary.HasValue ? distributionCenter.Anniversary.Value : DateTime.MinValue; distributionCenterDTO.Contact = distributionCenter.Contact; distributionCenterDTO.CreatedBy = distributionCenter.CreatedBy; distributionCenterDTO.CreatedDate = distributionCenter.CreatedDate; distributionCenterDTO.DateOfRegistration = distributionCenter.DateOfRegistration.HasValue ? distributionCenter.DateOfRegistration.Value : DateTime.MinValue; distributionCenterDTO.DCCode = distributionCenter.DCCode; distributionCenterDTO.DCId = distributionCenter.DCId; distributionCenterDTO.DCName = distributionCenter.DCName; distributionCenterDTO.DOB = distributionCenter.DOB.HasValue ? distributionCenter.DOB.Value : DateTime.MinValue; distributionCenterDTO.Email = distributionCenter.Email; distributionCenterDTO.FatherName = distributionCenter.FatherName; distributionCenterDTO.ModifiedBy = distributionCenter.ModifiedBy; distributionCenterDTO.ModifiedDate = distributionCenter.ModifiedDate.HasValue ? distributionCenter.ModifiedDate.Value : DateTime.MinValue; distributionCenterDTO.NoOfEmployee = distributionCenter.NoOfEmployee.GetValueOrDefault(); distributionCenterDTO.IsActive = distributionCenter.IsDeleted.GetValueOrDefault(); if (distributionCenter.DCWallets != null) { distributionCenterDTO.DcWalletBalance = distributionCenter.DCWallets.FirstOrDefault().WalletBalance; } if (distributionCenter.DCAddresses != null && distributionCenter.DCAddresses.Count() > 0) { distributionCenterDTO.DCAddressDTO = DCAddressConvertor.ConvertToDCAddressDTO(distributionCenter.DCAddresses.FirstOrDefault()); } return(distributionCenterDTO); }
public void SendSMSForMobileNumberVerfication(DistributionCenter distributionCenter) { SMSService sMSService = new SMSService(); string message = string.Format(unitOfWork.MessageRepository.GetMessageByMessageCode("DCSignUp", NatrajMessages.DCSignUpMessage), distributionCenter.Pin); sMSService.SendMessage(NatrajComponent.DC, SMSType.SignUp, distributionCenter.Contact, message); }
public Storage CreateStorage(string type, string name) { type = type.ToLower(); Storage storage = null; switch (type) { case "automatedwarehouse": storage = new AutomatedWarehouse(name); break; case "distributioncenter": storage = new DistributionCenter(name); break; case "warehouse": storage = new Warehouse(name); break; default: throw new InvalidOperationException("Invalid storage type!"); } return(storage); }
public void Add(DistributionCenter distributionCenter) { if (distributionCenter != null) { _repository.DistributionCenters.Add(distributionCenter); } }
private void CheckForExisitngDistributionCenter(DistributionCenterDTO distributionCenterDTO) { DistributionCenter existingDistributionCenter = null; if (string.IsNullOrWhiteSpace(distributionCenterDTO.DCCode) == false) { existingDistributionCenter = unitOfWork.DistributionCenterRepository.GetDistributionCenterByCode(distributionCenterDTO.DCCode); if (existingDistributionCenter != null) { throw new PlatformModuleException("Distribution Center Already Exist with given DC Code"); } } if (string.IsNullOrWhiteSpace(distributionCenterDTO.Contact) == false) { existingDistributionCenter = unitOfWork.DistributionCenterRepository.GetDistributionCenterByMobileNumber(distributionCenterDTO.Contact); if (existingDistributionCenter != null) { throw new PlatformModuleException("Distribution Center Already Exist with given Mobile Number"); } } if (string.IsNullOrWhiteSpace(distributionCenterDTO.Email) == false) { existingDistributionCenter = unitOfWork.DistributionCenterRepository.GetDistributionCenterByEmail(distributionCenterDTO.Email); if (existingDistributionCenter != null) { throw new PlatformModuleException("Distribution Center Already Exist with given Email"); } } }
public ResponseDTO AddDCOrder(CreateDCOrderDTO dCOrderDTO) { ResponseDTO responseDTO = new ResponseDTO(); DistributionCenter distributionCenter = unitOfWork.DistributionCenterRepository.GetById(dCOrderDTO.DCId); if (distributionCenter == null) { throw new PlatformModuleException("DC Details Not Found"); } else if (distributionCenter.DCAddresses != null && distributionCenter.DCAddresses.Count() == 0) { throw new PlatformModuleException("DC Address details Not Found"); } else { DCOrder dcOrder = new DCOrder(); dcOrder.DCOrderId = unitOfWork.DashboardRepository.NextNumberGenerator("DCOrder"); dcOrder.DCOrderNumber = distributionCenter.DCCode + "OD" + dcOrder.DCOrderId.ToString(); dcOrder.DCId = dCOrderDTO.DCId; dcOrder.OrderAddressId = distributionCenter.DCAddresses.FirstOrDefault().DCAddressId; dcOrder.OrderDate = DateTimeHelper.GetISTDateTime(); dcOrder.CreatedDate = DateTimeHelper.GetISTDateTime(); dcOrder.ModifiedDate = DateTimeHelper.GetISTDateTime(); dcOrder.CreatedBy = dcOrder.ModifiedBy = distributionCenter.AgentName; dcOrder.IsDeleted = false; dcOrder.OrderStatusId = (int)OrderStatus.Placed; dcOrder.DeliveryExpectedDate = DateTimeHelper.GetISTDateTime().AddDays(1); dcOrder.OrderComments = dCOrderDTO.OrderComments; if (dCOrderDTO.CreateDCOrderDtlList != null) { foreach (var dcOrderDtlDTO in dCOrderDTO.CreateDCOrderDtlList) { // this.CheckForExistingCollectionDetailByDateShiftProduct(vLCMilkCollection.CollectionDateTime.Value.Date, vLCMilkCollectionDTO.ShiftId, vlcCollectionDtlDTO.ProductId, vLCMilkCollectionDTO.CustomerId); DCOrderDtl dCOrderDtl = new DCOrderDtl(); dCOrderDtl.DCOrderDtlId = unitOfWork.DashboardRepository.NextNumberGenerator("DCOrderDtl"); dCOrderDtl.DCOrderId = dcOrder.DCOrderId; DCOrderConvertor.ConvertToDCOrderDtlEntity(ref dCOrderDtl, dcOrderDtlDTO, false); unitOfWork.DCOrderDtlRepository.Add(dCOrderDtl); } dcOrder.OrderTotalPrice = dCOrderDTO.CreateDCOrderDtlList.Sum(s => s.TotalPrice); dcOrder.TotalOrderQuantity = dCOrderDTO.CreateDCOrderDtlList.Sum(s => s.QuantityOrdered); dcOrder.TotalActualQuantity = dcOrder.TotalOrderQuantity; } else { throw new PlatformModuleException("DC Order Detail Not Found"); } unitOfWork.DCOrderRepository.Add(dcOrder); // UpdateOrderPaymentDetailsForOrder(distributionCenter, dcOrder); unitOfWork.SaveChanges(); responseDTO.Status = true; responseDTO.Message = String.Format("DC Order Placed Successfully "); responseDTO.Data = this.GetOrderDetailsByOrderId(dcOrder.DCOrderId); return(responseDTO); } }
public void Constructor_ShouldInitializeCorrectly() { Storage warehouse = new DistributionCenter("house"); Assert.AreEqual(5, warehouse.GarageSlots); Assert.AreEqual(2, warehouse.Capacity); Assert.AreEqual(3, this.distributionCenter.Garage.Count(v => v != null)); }
public ActionResult Edit(DistributionCenter model) { var dsService = new DistributionCenterService(); dsService.Update(model.Id, model); return(RedirectToAction("Index")); }
public void Check_For_Successful_Implementation_Of_Method_SendVehicleTo(int slot) { var targetStorage = new DistributionCenter("DistributionCenter"); this.storage.SendVehicleTo(slot, targetStorage); Assert.IsNull(this.storage.Garage.ToList()[slot]); }
public void TestDistributionCenterSendVehicleSendsVehiclesAndSetsTheDeliveryLocationCorrectly() { var distributionCenter = new DistributionCenter("SmartSolutions"); var automatedDistributionCenter = new AutomatedWarehouse("SmartTech"); distributionCenter.SendVehicleTo(0, automatedDistributionCenter); Assert.AreEqual(automatedDistributionCenter.Garage.ElementAt(1).GetType().Name, typeof(Van).Name, "When sending vehicles doesnt reflect in the delivery Storage."); }
public void TestDistributionCenterSendVehicleSendsVehicles() { var distributionCenter = new DistributionCenter("SmartSolutions"); var automatedDistributionCenter = new AutomatedWarehouse("SmartTech"); distributionCenter.SendVehicleTo(0, automatedDistributionCenter); Assert.AreEqual(distributionCenter.Garage.ElementAt(0), null, "When sending vehicles doesnt reflect in the current Storage."); }
internal static void Delete(int id) { EcommercePlatformDataContext db = new EcommercePlatformDataContext(); DistributionCenter dc = new DistributionCenter(); dc = db.DistributionCenters.Where(x => x.ID.Equals(id)).FirstOrDefault<DistributionCenter>(); db.DistributionCenters.DeleteOnSubmit(dc); db.SubmitChanges(); }
public void TestDistributionCenterPropertyIsFullReturnsFalse() { var distributionCenter = new DistributionCenter("SmartSolutions"); var hardDirve = new HardDrive(123); distributionCenter.GetVehicle(0).LoadProduct(hardDirve); distributionCenter.UnloadVehicle(0); Assert.IsFalse(distributionCenter.IsFull, "DistributionCenter should not be full."); }
public void TestDistributionCenterProperyProductsReturnsTheCorrectElements() { var distributionCenter = new DistributionCenter("SmartSolutions"); var hardDirve = new HardDrive(123); distributionCenter.GetVehicle(0).LoadProduct(hardDirve); distributionCenter.UnloadVehicle(0); Assert.AreEqual(distributionCenter.Products.ElementAt(0), hardDirve, "Product is not the same as expected."); }
public void TestSendVehicleWithIOE2() { Storage storage = new Warehouse("Pesho"); Storage destination = new DistributionCenter("Gosho"); storage.SendVehicleTo(0, destination); storage.SendVehicleTo(1, destination); Assert.Throws <InvalidOperationException>(() => { storage.SendVehicleTo(2, destination); }); }
public void TestDistributionCenterThrowsExceptionWhenDeliveryLocationIsfull() { var distributionCenter = new DistributionCenter("SmartSolutions"); var automatedDistributionCenter = new AutomatedWarehouse("SmartTech"); distributionCenter.SendVehicleTo(0, automatedDistributionCenter); Assert.Throws <InvalidOperationException>(() => distributionCenter.SendVehicleTo(1, automatedDistributionCenter), "Doesnt throw exception when delivery location is full."); }
public virtual int Update(DistributionCenter distrubutionCenter) { var curr_distributionCenter = Context.DistributionCenter.First(x => x.DistributionCenterId == distrubutionCenter.DistributionCenterId); curr_distributionCenter.PhoneNumber = distrubutionCenter.PhoneNumber; curr_distributionCenter.Name = distrubutionCenter.Name; curr_distributionCenter.Address = distrubutionCenter.Address; Context.SaveChanges(); return(distrubutionCenter.DistributionCenterId); }
public void TestDistributionCenterUnloadProductReturnsTheCorrectNumberOfUnloadedProducts() { var distributionCenter = new DistributionCenter("SmartSolutions"); var hardDirve = new HardDrive(123); distributionCenter.GetVehicle(0).LoadProduct(hardDirve); distributionCenter.GetVehicle(0).LoadProduct(hardDirve); Assert.AreEqual(distributionCenter.UnloadVehicle(0), 2, "Doesnt unload the correct number of products"); }
public void SendVehicle_ShouldThrowException() { Storage tempStorage = new DistributionCenter("Temp"); for (int i = 3; i < tempStorage.Garage.Count; i++) { this.distributionCenter.SendVehicleTo(i % 3, tempStorage); } Assert.Throws <InvalidOperationException>(() => this.distributionCenter.SendVehicleTo(5, tempStorage), "No room in garage!"); }
public void TestDistributionCenterUnloadProductThrowsExceptionWhenStorageIsfull() { var distributionCenter = new DistributionCenter("SmartSolutions"); var hardDirve = new HardDrive(123); distributionCenter.GetVehicle(0).LoadProduct(hardDirve); distributionCenter.GetVehicle(0).LoadProduct(hardDirve); distributionCenter.UnloadVehicle(0); distributionCenter.GetVehicle(0).LoadProduct(hardDirve); Assert.Throws <InvalidOperationException>(() => distributionCenter.UnloadVehicle(0), "Doesnt Throw Exception when storage house if full."); }
public void AddDistributionCenterWallet(DistributionCenter distributionCenter) { DCWallet dCWallet = new DCWallet(); dCWallet.WalletId = unitOfWork.DashboardRepository.NextNumberGenerator("DCWallet"); dCWallet.DCId = distributionCenter.DCId; dCWallet.WalletBalance = 0; dCWallet.AmountDueDate = DateTimeHelper.GetISTDateTime().AddDays(10); distributionCenter.DCWallets.Add(dCWallet); // unitOfWork.DCWalletRepository.Add(dCWallet); }
internal static DistributionCenter Get(int id) { try { DistributionCenter dc = new DistributionCenter(); EcommercePlatformDataContext db = new EcommercePlatformDataContext(); dc = db.DistributionCenters.Where(x => x.ID.Equals(id)).FirstOrDefault<DistributionCenter>(); return dc; } catch (Exception) { return new DistributionCenter(); } }
public ActionResult Save(int id = 0, string Name = "", string Phone = "", string Fax = "", string Street1 = "", string Street2 = "", string City = "", int State = 0, string PostalCode = "") { DistributionCenter dc = new DistributionCenter(); List<string> errors = new List<string>(); try { DC.Save(id, Name, Phone, Fax, Street1, Street2, City, State, PostalCode, out dc, out errors); if (errors.Count > 0) { throw new Exception(); } return RedirectToAction("Index", "Distribution"); } catch (Exception) { TempData["errors"] = errors; TempData["dc"] = dc; return RedirectToAction("Edit", "Distribution", new { id = id, failed = true }); } }
internal static void Save(int id, string Name, string Phone, string Fax, string Street1, string Street2, string City, int State, string PostalCode, out DistributionCenter dc, out List<string> errors) { EcommercePlatformDataContext db = new EcommercePlatformDataContext(); dc = new DistributionCenter(); errors = new List<string>(); if (id != 0) { dc = db.DistributionCenters.Where(x => x.ID.Equals(id)).FirstOrDefault<DistributionCenter>(); } try { // Validate the fields if (Name.Length == 0) { throw new Exception(); } else { dc.Name = Name; } if (Phone.Length == 0) { throw new Exception(); } else { dc.Phone = Phone; } if (Street1.Length == 0) { throw new Exception(); } else { dc.Street1 = Street1; } if (City.Length == 0) { throw new Exception(); } else { dc.City = City; } if (State == 0) { throw new Exception(); } else { dc.State = State; } if (PostalCode.Length == 0) { throw new Exception(); } else { dc.PostalCode = PostalCode; } dc.Fax = Fax; dc.Street2 = Street2; // Geocode the DC GeocodingResponse geo = Geocoding.GetGeoLocation(dc.Street1 + " " + dc.Street2, dc.City, 0, dc.PostalCode, dc.State1.Country.abbr, dc.State1.abbr); LatitudeLongitude latLon = new LatitudeLongitude(); if (geo.results.Count > 0) { latLon = geo.results[0].geometry.location; dc.Latitude = latLon.lat; dc.Longitude = latLon.lng; } else { errors.Add("Failed to retrieve geographical location."); } if (errors.Count == 0) { if (id == 0) { db.DistributionCenters.InsertOnSubmit(dc); } db.SubmitChanges(); } } catch (Exception e) { errors.Add(e.Message); } }
public ShippingResponse getShipping(HttpContext ctx) { Customer customer = new Customer(); Settings settings = ViewBag.settings; customer.GetFromStorage(ctx); FedExAuthentication auth = new FedExAuthentication { AccountNumber = Convert.ToInt32(settings.Get("FedExAccount")), Key = settings.Get("FedExKey"), Password = settings.Get("FedExPassword"), CustomerTransactionId = "", MeterNumber = Convert.ToInt32(settings.Get("FedExMeter")) }; customer.Cart.BindAddresses(); ShippingAddress destination = new ShippingAddress(); try { destination = customer.Cart.Shipping.getShipping(); } catch (Exception) { Response.Redirect("/Cart/Checkout"); } DistributionCenter d = new DistributionCenter().GetNearest(customer.Cart.Shipping.GeoLocate()); ShippingAddress origin = d.getAddress().getShipping(); List<int> parts = new List<int>(); foreach (CartItem item in customer.Cart.CartItems) { for (int i = 1; i <= item.quantity; i++) { parts.Add(item.partID); } } ShippingResponse response = CURTAPI.GetShipping(auth, origin, destination, parts); return response; }