public StoreDTO CreateStore(StoreDTO store) { var userId = _userbusiness.GetByName(store.UserName).Result.ID; store.CreatedDate = System.DateTime.Now; store.ModifiedDate = System.DateTime.Now; store.StatusID = WAITINGFORAPPROVE; store.UserID = userId; store.CityId = _city.GetByName(store.City).Id; store.CountryId = _country.GetByName(store.Country).Id; var DisString = store.District.Split('.'); if (DisString.Length > 1) { store.DistrictId = _district.GetByName(DisString[1]).Id; } else if (DisString.Length == 1) { store.DistrictId = _district.GetByName(DisString[0]).Id; } store.ModifiedByID = userId; store.LimitProduct = PACKAGE1; store = _repo.Create(BusinessTranslators.ToStoreEntity(store)).Translate <Store, StoreDTO>(); return(store); }
public async Task <IActionResult> Edit(int id, StoreViewModel store) { if (id != store.Id) { return(NotFound()); } if (ModelState.IsValid) { try { StoreDTO storeDTO = new StoreDTO() { Id = store.Id, Name = store.Name, Address = store.Address, OpeningTimes = store.OpeningTimes }; await _storeService.UpdateStore(storeDTO); } catch (DbUpdateConcurrencyException) { //if (!StoreExists(store.Id)) //{ // return NotFound(); //} //else //{ // throw; //} } return(RedirectToAction(nameof(Index))); } return(View(store)); }
public StoreDTO GetById(int id) { StoreDTO store = _repo.FindByID(id).Translate <Store, StoreDTO>(); store.Products = _productbusiness.GetAllByStore(store.ID); return(store); }
public async Task <IHttpActionResult> PutStore(int entityId, StoreDTO value) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (value.EntityId != entityId) { return(BadRequest()); } DbContext.Entry(value).State = EntityState.Modified; try { await DbContext.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ValueExists(entityId)) { return(NotFound()); } throw; } return(StatusCode(HttpStatusCode.NoContent)); } catch (Exception ex) { Log.Error("Store.Put: " + ex); throw; } }
public StoreDTO GetStoreByUser(string strUserName) { StoreDTO strToReturn = null; UserDTO userUser = this.GetUserDTOByUserName(strUserName); if (userUser != null && userUser.profile != null && userUser.profile.address != null) { int?cityCode = userUser.profile.address.city; if (cityCode.HasValue) { CityDTO city = this.Cities.Where(x => x._id == cityCode.Value).FirstOrDefault(); if (city != null) { strToReturn = this.GetStoreByCity(city.cityName); } } } if (strToReturn == null) { strToReturn = this.Stores.FirstOrDefault(); } return(strToReturn); }
public async Task <IActionResult> StoreDetails(Guid id) { StoreDTO storeDTO = new StoreDTO(); Store store = await _storesRepository.GetById(id); storeDTO.Name = store.Name; storeDTO.Description = store.Description; storeDTO.Website = store.Website; List <ProductDTO> productDTOs = new List <ProductDTO>(); IEnumerable <ProductStore> productStores = await _productStoresRepository.GetByStore(id); foreach (var productStore in productStores) { Product product = await _productsRepository.GetById(productStore.ProductId); ProductDTO productDTO = new ProductDTO { Name = product.Name, Brand = product.Brand, Quantity = product.Quantity, UnitOfMeasurement = product.UnitOfMeasurement }; productDTOs.Add(productDTO); } storeDTO.Products = productDTOs; return(Ok(storeDTO)); }
public bool CreateStore([FromBody] StoreDTO store) { var s = store.ToStore(); bool exists = _StoreRepository.Add(s); return(exists); }
public ApiResponse DeleteStore([FromBody] StoreDTO store) { SystemFail error = new SystemFail(); ApiResponse response = new ApiResponse(); if (store != null && !error.Error) { Store deletStore = new Store(); deletStore.Id = store.Id; deletStore.Name = store.Name; deletStore.Address = store.Address; storeService.DeleteStore(deletStore, error); if (!error.Error) { response.Message = "La tienda fue eliminada exitosamente."; response.success = true; } else { response.Message = string.Concat("No fue posible eliminar la tienda. Error: ", error.Message); response.success = false; } } else { response.Message = "Ha ocurrido un error. La tienda con el Id especificado , no fue encontrada"; response.success = false; } return(response); }
public JsonResponse <StoreDTO> UpdateStoreProfile(long userID, int storeID, string contactPerson, string mobileNo, string emailID, string imageName, string storeAddress) { JsonResponse <StoreDTO> response = new JsonResponse <StoreDTO>(); try { ExceptionEngine.AppExceptionManager.Process(() => { StoreDTO storeDTO = new StoreDTO(); contactPerson = System.Web.HttpUtility.HtmlEncode(contactPerson); mobileNo = System.Web.HttpUtility.HtmlEncode(mobileNo); emailID = System.Web.HttpUtility.HtmlEncode(emailID); imageName = System.Web.HttpUtility.HtmlEncode(imageName); storeAddress = System.Web.HttpUtility.HtmlEncode(storeAddress); StoreBO storeBO = StoreBusinessInstance.UpdateStoreProfile(storeID, contactPerson, mobileNo, emailID, imageName, storeAddress); EntityMapper.Map(storeBO, storeDTO); if (storeDTO != null) { response.IsSuccess = true; response.Message = "Store details updated successfully"; } else { response.IsSuccess = false; response.Message = "Store details couldn't be updated"; } }, AspectEnums.ExceptionPolicyName.ServiceExceptionPolicy.ToString()); } catch (Exception ex) { response.Message = ex.Message; } return(response); }
public ApiResponse UpdateStore([FromBody] StoreDTO store) { SystemFail error = new SystemFail(); ApiResponse response = new ApiResponse(); if (ModelState.IsValid) { Store updatedStore = new Store(); updatedStore.Address = store.Address; updatedStore.Id = store.Id; updatedStore.Name = store.Name; storeService.UpdateStore(updatedStore, error); if (!error.Error) { response.Message = "La tienda fue actualizada exitosamente."; response.success = true; } else { response.Message = string.Concat("No fue posible actualizar la tienda. Error: ", error.Message); response.success = false; } } else { response.Message = string.Concat("Ha ocurrido un error al validar la entidad. Error:", string.Join(";", ModelState.Values.Select(x => x.Errors.Select(e => e.ErrorMessage)))); response.success = false; } return(response); }
public StoreDTO GetStorebyId(int id) { Store store = context.Stores.Find(id); StoreDTO storeDTO = mapper.Map <StoreDTO>(store); return(storeDTO); }
public ApiResponse CreateStore([FromBody] StoreDTO store, string dummy) { SystemFail error = new SystemFail(); ApiResponse response = new ApiResponse(); if (ModelState.IsValid) { Store newStore = new Store(); newStore.Address = store.Address; newStore.Id = store.Id; newStore.Name = store.Name; storeService.CreateStore(newStore, error); if (!error.Error) { response.success = true; response.Message = "Se creo correctamente la tienda"; } else { response.success = false; response.Message = string.Concat("Ha ocurrido un error. Error:", error.Message); } } else { response.success = false; response.Message = string.Concat("Ha ocurrido un error al validar la entidad. Error:", string.Join(";", ModelState.Values.Select(x => x.Errors.Select(e => e.ErrorMessage)))); } return(response); }
public bool Put(StoreDTO store, string name) { var userId = _userbusiness.GetByName(store.UserName).Result.ID; store.ModifiedDate = System.DateTime.Now; store.CityId = _city.GetByName(store.City).Id; store.CountryId = _country.GetByName(store.Country).Id; var DisString = store.District.Split('.'); if (DisString.Length > 1) { store.DistrictId = _district.GetByName(DisString[1]).Id; } else if (DisString.Length == 1) { store.DistrictId = _district.GetByName(DisString[0]).Id; } store.ModifiedByID = userId; if (string.IsNullOrEmpty(store.ImgLink)) { store.ImgLink = _repo.FindByID(store.ID).ImgLink; } var result = _repo.Edit(BusinessTranslators.ToStoreEntity(store)); return(result); }
public IHttpActionResult GetStoreById(string id) { int idInt = 0; var response = new SingularStoreResponse(); var result = new StoreDTO(); try { // Validate request if (string.IsNullOrEmpty(id) || !int.TryParse(id, out idInt)) { return(Ok(ResponseHandler.Error(400))); } result = ContextBehaviours.GetStoreById(idInt); // Validate if find record if (result == null) { return(Ok(ResponseHandler.Error(404))); } // Prepare success response response.store = result; response.success = true; return(Ok(response)); } catch (Exception ex) { return(Ok(ResponseHandler.Error(500))); } }
public void Put(string id, [FromBody] StoreDTO value) { var store = this.service.Get(id); TryValidateModel(value); this.mapper.Map <StoreDTO, Store>(value, store); this.service.Update(store); }
public StoreDTO GetStoreWithInventory(string storeId) { Guid guid = Guid.Parse(storeId); var store = _StoreRepository.GetStoreWithInventory(guid); var storeDto = new StoreDTO(store); return(storeDto); }
public async Task <ActionResult <StoreDTO> > PostStore(StoreDTO storeDTO) { Store store = DtoToItem(storeDTO); await storeDA.PostStore(store); return(new CreatedAtActionResult(nameof(GetStore), "Stores", new { Id = store.Id }, ItemToDTO(store))); }
public IActionResult AddStore(StoreDTO NewStore) { if (storeServices.SaveStoreData(NewStore) == true) { return(RedirectToAction("ListStore")); } return(View()); }
public void Create(StoreDTO storeDTO) { Store store = new Store(); store.Store_Name = storeDTO.Store_Name; dbcontext.Stores.Add(store); dbcontext.SaveChanges(); }
public async Task <IActionResult> Create([FromBody] StoreDTO storeDTO) { var store = Store.Create(storeDTO.Name, storeDTO.Description, storeDTO.Website); await _storesRepository.Add(store); return(Ok(store)); }
public ActionResult Put(string id, [FromBody] StoreDTO value) { var store = service.Get(id); TryValidateModel(value); mapper.Map <StoreDTO, Store>(value, store); service.Update(store); return(NoContent()); }
public List <StoreDTO> FindStores(SearcClothDTO search) { StoreDTO SDTO = new StoreDTO(); try { List <InventoryDTO> list = new List <InventoryDTO>(); List <StoreDTO> retval = new List <StoreDTO>(); int compID = 0; int clothcod = 0; using (db = new storesEntities()) { var company = db.Companys.SingleOrDefault(comp => comp.CompanyName == search.CompanyName); if (company != null) { compID = company.CompanyID; } var cloth = db.Clothes.SingleOrDefault(c => c.ClothCompaniCod == search.ClothCompaniCod && c.CompanyId == compID); if (cloth != null) { clothcod = cloth.ClothID; } list = db.Inventories.Where(i => i.ClothID == clothcod).Select(inve => new InventoryDTO() { ClothID = inve.ClothID, StoreID = inve.StoreID, YearOfProduction = inve.YearOfProduction }).ToList <InventoryDTO>(); foreach (var item in list) { var record = db.Stores.Where(store => store.StoreID == item.StoreID).FirstOrDefault(); if (record != null) { retval.Add(SDTO.ToDTO(record)); } } return(retval); } //using (db = new storesEntities()) //{ // int ComId = db.Companys.Where(com => com.CompanyName == search.CompanyName).First().CompanyID;//קוד החברה // //קוד הבגד הרצוי // int ClothId = db.Clothes.Where(c => c.Describe == search.Describe && c.Color == search.Color && c.ClothID == search.ClothId && c.CompanyId == ComId).First().ClothID; // List<int> AllStoresId = db.InventoryCloth.Where(inv => inv.ClothId == ClothId).ToList<int>();//הקודים של כל החנויות שיש להם את הבגד // List<Store> AllStores = db.Stores.Where(s => AllStoresId.Where(f => f == s.StoreID).Count() != 0).ToList<Store>();//כל החנויות שיש להם את הבגד // List<StoreDTO> RetList=new List<StoreDTO>(); // foreach (Store ss in AllStores) // { // RetList.Add(SDTO.ToDTO(ss)); // } // return RetList; //} } catch (Exception e) { throw; } }
public IActionResult DeleteStore(StoreDTO store) { if (storeServices.DeleteStoreData(store) == true) { return(RedirectToAction("ListStore")); } return(View()); }
public bool DeleteStoreData(StoreDTO deletestore) { context.Stores.Remove(mapper.Map <Store>(deletestore)); if (context.SaveChanges() == 1) { return(true); } return(false); }
public bool UpdateStoreData(StoreDTO store) { context.Stores.Update(mapper.Map <Store>(store)); if (context.SaveChanges() == 1) { return(true); } return(false); }
public async Task <StoreDTO> CreateAsync(StoreDTO entity) { var entitie = Mapper.Map <StoreDTO, Stores>(entity); _context.Stores.Add(entitie); await _context.SaveChangesAsync(); return(Mapper.Map <Stores, StoreDTO>(entitie)); }
/// <summary> /// 得到门店详细信息 /// </summary> /// <param name="id">门店ID</param> /// <returns></returns> public Jinher.AMP.BTP.Deploy.StoreDTO GetStoreDTOExt(System.Guid id, Guid appid) { var storeQuery = Query <StoreMgDTO> .Where(c => c.Id == id); StoreMgDTO smg = MongoCollections.Store.FindOneAs <StoreMgDTO>(storeQuery); StoreDTO store = MongoToDto(smg); return(store); }
/// <summary> /// 修改操作 /// </summary> public void Updates(StoreDTO storeDTO) { ContextSession contextSession = ContextFactory.CurrentThreadContext; storeDTO.EntityState = System.Data.EntityState.Modified; Store store = new Store().FromEntityData(storeDTO); contextSession.SaveObject(store); contextSession.SaveChanges(); }
public void Edit(StoreDTO storeDTO) { Store store = new Store(); store.Store_ID = storeDTO.Store_ID; store.Store_Name = storeDTO.Store_Name; dbcontext.Entry(store).State = EntityState.Modified; dbcontext.SaveChanges(); }
public Task <CommandResult> CreateStore(StoreDTO store) { var command = new CreateStoreCommand { StoreId = Guid.NewGuid().ToString(), ManagerName = store.ManagerName }; return(commandBus.Send <CreateStoreCommand, CommandResult>(command)); }
public IList<StoreDTO> GetStores() { var storeList = new List<StoreDTO>(); var stores = _storeRepository.GetAll(); foreach (var item in stores) { var store = new StoreDTO() { Id = item.Id, Name = item.Name }; storeList.Add(store); } return storeList; }
private StoreDTO Map(tblCostCentre tbl) { var dto = new StoreDTO { MasterId = tbl.Id, DateCreated = tbl.IM_DateCreated, DateLastUpdated = tbl.IM_DateLastUpdated, StatusId = tbl.IM_Status, CostCentreCode = tbl.Cost_Centre_Code, Name = tbl.Name, ParentCostCentreId = tbl.ParentCostCentreId ?? Guid.Empty, CostCentreTypeId = tbl.CostCentreType ?? 0, Longitude = tbl.StandardWH_Longtitude, Latitude = tbl.StandardWH_Latitude, VatRegistrationNo = tbl.StandardWH_VatRegistrationNo }; return dto; }
public Store Map(StoreDTO dto) { if (dto == null) return null; var store = Mapper.Map<StoreDTO, Store>(dto); return store; }
static void Main(string[] args) { Thread geocodeThread = new Thread(new ThreadStart(Geocode.Work)); geocodeThread.Start(); while (!geocodeThread.IsAlive) ; HtmlWeb client = new HtmlWeb(); HtmlDocument doc = client.Load(BASE + "default.aspx?template=results&abc=show&abc-field=Offence_City&startswith=A,Offence_City"); HtmlNodeCollection nav = doc.DocumentNode.SelectNodes("//div[@id='abc']//a"); navCount = nav.Count; foreach (HtmlNode navLink in nav) { //if(navProcess == 1) break; navProcess++; Console.WriteLine("Processing " + navProcess + "/" + navCount); string suburbURL = navLink.Attributes["href"].Value; HtmlNodeCollection suburb = GetSuburb(suburbURL); if(suburb == null) continue; int storeCount = suburb.Count; int storeProcess = 0; foreach (HtmlNode stores in suburb) { storeProcess++; Console.WriteLine("\t> Processing " + storeProcess + "/" + storeCount); string storeDetailsURL = stores.Attributes["href"].Value; HtmlNode storeDetails = GetDetails(storeDetailsURL); string storeKey = storeDetails.SelectSingleNode("//tr[2]/td[2]").InnerText; StoreDTO processStore = StoresList.Find(item => item.TradeName == storeKey); if (processStore == null) { lock (StoresList) { processStore = new StoreDTO { TradeName = storeKey, Address = storeDetails.SelectSingleNode("//tr[3]/td[2]").InnerText, Council = storeDetails.SelectSingleNode("//tr[4]/td[2]").InnerText, }; StoresList.Add(processStore); } } OffencesDTO offence = new OffencesDTO { PenaltyNoticeNumber = storeDetails.SelectSingleNode("//tr[1]/td[2]").InnerText, DateAlleged = storeDetails.SelectSingleNode("//tr[5]/td[2]").InnerText, OffenceCode = storeDetails.SelectSingleNode("//tr[6]/td[2]").InnerText, NatureCircumstances = storeDetails.SelectSingleNode("//tr[7]/td[2]").InnerText, PenaltyAmount = storeDetails.SelectSingleNode("//tr[8]/td[2]").InnerText, NamePartyServed = storeDetails.SelectSingleNode("//tr[9]/td[2]").InnerText, DatePenaltyNoticeServed = storeDetails.SelectSingleNode("//tr[10]/td[2]").InnerText, IssuedBy = storeDetails.SelectSingleNode("//tr[11]/td[2]").InnerText, Notes = storeDetails.SelectSingleNode("//tr[12]/td[2]").InnerText }; processStore.Offences.Add(offence); } } IsProcessing = false; geocodeThread.Join(); Console.WriteLine("Waiting for geocoder"); File.WriteAllText("data.json", JsonConvert.SerializeObject(StoresList)); Console.WriteLine("Finished"); Console.ReadLine(); }
public IList<LineItemDTO> GetLineItems(Guid storeId, Guid commodityId, Guid gradeID) { var lineItemList = new List<LineItemDTO>(); var commodityTransfer = _commodityTransferRepository.GetAll(); foreach (CommodityTransferNote sourcingDocument in commodityTransfer.Where(n => n.DocumentIssuerCostCentre.Id.Equals(storeId))) { if (sourcingDocument.Status != DocumentSourcingStatus.Approved) continue; foreach (var items in sourcingDocument.LineItems) { if (items.Commodity.Id.Equals(commodityId) && items.CommodityGrade.Id.Equals(gradeID) && items.LineItemStatus == SourcingLineItemStatus.New) { var store = _storeRepository.GetById(storeId); var itemStore = new StoreDTO() { Id = store.Id, Name = store.Name }; var commodity = new CommodityDTO() { Id = items.Commodity.Id, Name = items.Commodity.Name }; var grade = new GradeDTO() { Id = items.CommodityGrade.Id, Name = items.CommodityGrade.Name }; var item = new LineItemDTO() { BatchNo = items.ContainerNo, Store = itemStore, Commodity = commodity, Grade = grade, IsSelected = false, Id = items.Id, Weight = items.Weight }; lineItemList.Add(item); } } } return lineItemList; }