private void SetStoresForEdit(Data.StoreOrder storeOrder, Data.BaseInfo repository, Data.Goody goody, Data.Com company, Data.PriceList priceList) { try { using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions() { IsolationLevel = System.Transactions.IsolationLevel.ReadUncommitted, Timeout = new TimeSpan(2, 0, 0) })) { var storeDetails = Business.GetStoreOrderDetailBusiness().GetByStoreOrderId(storeOrder.Id).ToList(); var currentStores = Business.GetStoreSBusiness().GetByStoreOrderDetailIds(storeDetails.Select(r => r.Id).ToList()); var stores = new List <Data.Store>(); foreach (var item in storeDetails) { var currentStore = currentStores.Find(r => r.IdStoreOrderDetail == item.Id); var previousStore = Business.GetStoreSBusiness().GetLastForCommodity(item.IdCommodity); var remained = 0; if (previousStore != null) { remained = previousStore.SRemained.ToInt(); } var coef = Business.GetGoodyConvertCountingUnitBusiness().FindCoefficient(item.IdCommodity, goody.CBaseCountingUnit.ToGUID(), item.ODCountingUnit); var store = new Data.Store() { IdStoreOrderDetail = item.Id, RegDate = currentStore == null ? DateTime.Now : currentStore.RegDate, EditDate = DateTime.Now, SCount = item.ODCount, SRemained = remained + currentStore.SCount - (item.ODCount * coef).ToInt(), Sname = repository.Id, IdStoreOperation = Common.Constants.StoreOperation.PurchaseInvoice, IdCommodity = item.IdCommodity }; Business.GetStoreSBusiness().Insert(store); item.IdStoreS = store.Id; } Business.GetStoreOrderDetailBusiness().SubmitChanges(); Business.GetStoreSBusiness().Delete(currentStores); scope.Complete(); } } catch { throw; } }
public static List<MinimalPersonViewModel> GetAllPeople() { List<MinimalPersonViewModel> results; Mapper.CreateMap<Person, MinimalPersonViewModel>(); using(var dataStore = new Store()) { results = Mapper.Map<List<Person>, List<MinimalPersonViewModel>>(dataStore.People.ToList()); } return results; }
public static MinimalPersonViewModel GetOneMinimalPersonByRecordId(int recordId) { MinimalPersonViewModel result; Mapper.CreateMap<Person, MinimalPersonViewModel>(); using (var dataStore = new Store()) { var theRecord = dataStore.People.FirstOrDefault(x => x.RecordId == recordId); result = theRecord != null ? Mapper.Map<Person, MinimalPersonViewModel>(theRecord) : null; } return result; }
public void Insert(Data.Store store) { try { if (store.Id == Guid.Empty) { store.Id = Guid.NewGuid(); } this.Table.Add(store); this.SubmitChanges(); } catch { throw; } }
public static void UpdateFullPerson(FullPersonViewModel personDetails) { Mapper.CreateMap<FullPersonViewModel, Person>() .ForMember(dest => dest.RecordId, opt => opt.Ignore()); using(var dataStore = new Store()) { var originalRecord = dataStore.People.Find(personDetails.RecordId); if(originalRecord != null) { originalRecord = Mapper.Map<FullPersonViewModel, Person>(personDetails, originalRecord); } dataStore.SaveChanges(); } }
public void Delete(Data.Store entity) { try { if (entity == null) { return; } this.Delete(new List <Data.Store>() { entity }); } catch { throw; } }
public ActionResult AddStore(AddStoreViewModel model) { if (!this.ModelState.IsValid) { return this.View(model); } var userId = this.User.Identity.GetUserId(); var store = new Store(); store.UserId = userId; store.Name = model.Name; store.Username = model.Username; store.Password = model.Password; store.Url = model.Url; this.stores.Add(store); this.stores.SaveChanges(); return this.View(); }