public async Task <IActionResult> Edit(Guid id, [Bind("ItemsGroupID,ItemsGroupCode,ItemsGroupName,ItemsGroupNameEN,ItemsGroupNameRU,ParentItemsGroupID")] ItemsGroup itemsGroup) { if (id != itemsGroup.ItemsGroupID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(itemsGroup); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ItemsGroupExists(itemsGroup.ItemsGroupID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ParentItemsGroupID"] = new SelectList(_context.ItemsGroups, "ItemsGroupID", "ItemsGroupCode", itemsGroup.ParentItemsGroupID); return(View(itemsGroup)); }
public async Task <IActionResult> Create([Bind("ItemsGroupID,ItemsGroupCode,ItemsGroupName,ItemsGroupNameEN,ItemsGroupNameRU,ParentItemsGroupCode")] ItemsGroup itemsGroup) { if (ModelState.IsValid) { itemsGroup.ItemsGroupID = Guid.NewGuid(); _context.Add(itemsGroup); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(itemsGroup)); }
public void Create() { var data = ItemsGroupInput(); ItemsGroup group = new ItemsGroup(); group.ItemsGroupCode = data["code"]; group.ItemsGroupName = data["name"]; group.ItemsGroupNameEN = data["nameEN"]; group.ItemsGroupNameRU = data["nameRU"]; group.ParentItemsGroupID = null; Console.WriteLine("Please enter Parent Group Name, or none"); string groupName = Console.ReadLine(); if (groupName != "none") { var parent = _context.ItemsGroups.Where(g => g.ItemsGroupName == groupName).FirstOrDefault(); group.ParentItemsGroup = parent; } _context.Add(group); _context.SaveChanges(); }
// Список государственных закупок public ActionResult Tender(int?year) { using (zcrlDbContext = new ZcrlContext()) { if (!year.HasValue) { var requiredYear = (from y in zcrlDbContext.TenderItems orderby y.Year.Value descending select y).FirstOrDefault(); if (requiredYear != null) { return(Tender(requiredYear.Year.Value)); } else { return(RedirectToAction("News")); } } var yearFiles = (from it in zcrlDbContext.TenderItems.Include("RelatedFile").Include("Year").Include("RelatedGroup").Include("RelatedFile.Author") where (it.Year.Value == year.Value) select it).ToList(); var reqiredFiles = (from item in yearFiles orderby item.PublicationDate descending group item by item.RelatedGroup into ItemsGroup select new TenderItemGroup() { GroupName = (ItemsGroup.Key == null) ? "Без тендерної категорії" : ItemsGroup.Key.Name, Items = ItemsGroup.ToList() }).ToList(); if (reqiredFiles.Count == 0) { return(RedirectToAction("NotFound", "Error")); } else { return(View(reqiredFiles)); } } }
public static void OpenEntityForEdit(SourceItemId entity) { object id; long intId; object type; switch (entity.Table) { case DbTable.Unknown: break; case DbTable.ApplicationLog: break; case DbTable.Cashbook: break; case DbTable.Configuration: break; case DbTable.Currencies: break; case DbTable.CurrenciesHistory: break; case DbTable.Documents: id = entity [DataField.DocumentOperationNumber]; type = entity [DataField.DocumentType]; if (type == null) { break; } try { type = Enum.ToObject(typeof(OperationType), type); intId = Convert.ToInt64(id); } catch (Exception ex) { ErrorHandling.LogException(ex); break; } FormHelper.EditOperation((OperationType)type, intId); break; case DbTable.EcrReceipts: break; case DbTable.Items: id = entity [DataField.ItemId]; try { intId = Convert.ToInt64(id); } catch (Exception ex) { ErrorHandling.LogException(ex); break; } if (BusinessDomain.RestrictionTree.GetRestriction("mnuEditGoodsbtnEdit") != UserRestrictionState.Allowed) { break; } using (EditNewItem dialog = new EditNewItem(Item.GetById(intId))) if (dialog.Run() == ResponseType.Ok) { using (new DbMasterScope(BusinessDomain.DataAccessProvider)) dialog.GetItem().CommitChanges(); } break; case DbTable.ItemsGroups: id = entity [DataField.ItemGroupId]; try { intId = Convert.ToInt64(id); } catch (Exception ex) { ErrorHandling.LogException(ex); break; } if (BusinessDomain.RestrictionTree.GetRestriction("mnuEditGoodsbtnEdit") != UserRestrictionState.Allowed) { break; } using (EditNewGroup <ItemsGroup> dialog = new EditNewGroup <ItemsGroup> (ItemsGroup.GetById(intId), ItemsGroup.GetAll())) if (dialog.Run() == ResponseType.Ok) { using (new DbMasterScope(BusinessDomain.DataAccessProvider)) dialog.GetGroup().CommitChanges(); } break; case DbTable.InternalLog: break; case DbTable.Lots: break; case DbTable.Network: break; case DbTable.NextAcct: break; case DbTable.Objects: id = entity [DataField.LocationId]; try { intId = Convert.ToInt64(id); } catch (Exception ex) { ErrorHandling.LogException(ex); break; } if (BusinessDomain.RestrictionTree.GetRestriction("mnuEditObjectsbtnEdit") != UserRestrictionState.Allowed) { break; } using (EditNewLocation dialog = new EditNewLocation(Location.GetById(intId))) if (dialog.Run() == ResponseType.Ok) { using (new DbMasterScope(BusinessDomain.DataAccessProvider)) dialog.GetLocation().CommitChanges(); } break; case DbTable.ObjectsGroups: id = entity [DataField.LocationsGroupsId]; try { intId = Convert.ToInt64(id); } catch (Exception ex) { ErrorHandling.LogException(ex); break; } if (BusinessDomain.RestrictionTree.GetRestriction("mnuEditObjectsbtnEdit") != UserRestrictionState.Allowed) { break; } using (EditNewGroup <LocationsGroup> dialog = new EditNewGroup <LocationsGroup> (LocationsGroup.GetById(intId), LocationsGroup.GetAll())) if (dialog.Run() == ResponseType.Ok) { using (new DbMasterScope(BusinessDomain.DataAccessProvider)) dialog.GetGroup().CommitChanges(); } break; case DbTable.Operations: type = entity [DataField.OperationType]; if (type == null) { break; } id = entity [DataField.OperationNumber]; try { type = Enum.ToObject(typeof(OperationType), type); intId = Convert.ToInt64(id); } catch (Exception ex) { ErrorHandling.LogException(ex); break; } FormHelper.EditOperation((OperationType)type, intId); break; case DbTable.OperationDetails: break; case DbTable.OperationType: break; case DbTable.Partners: id = entity [DataField.PartnerId]; try { intId = Convert.ToInt64(id); } catch (Exception ex) { ErrorHandling.LogException(ex); break; } if (BusinessDomain.RestrictionTree.GetRestriction("mnuEditPartnersbtnEdit") != UserRestrictionState.Allowed) { break; } using (EditNewPartner dialog = new EditNewPartner(Partner.GetById(intId))) if (dialog.Run() == ResponseType.Ok) { using (new DbMasterScope(BusinessDomain.DataAccessProvider)) dialog.GetPartner().CommitChanges(); } break; case DbTable.PartnersGroups: id = entity [DataField.PartnersGroupsId]; try { intId = Convert.ToInt64(id); } catch (Exception ex) { ErrorHandling.LogException(ex); break; } if (BusinessDomain.RestrictionTree.GetRestriction("mnuEditPartnersbtnEdit") != UserRestrictionState.Allowed) { break; } using (EditNewGroup <PartnersGroup> dialog = new EditNewGroup <PartnersGroup> (PartnersGroup.GetById(intId), PartnersGroup.GetAll())) if (dialog.Run() == ResponseType.Ok) { using (new DbMasterScope(BusinessDomain.DataAccessProvider)) dialog.GetGroup().CommitChanges(); } break; case DbTable.Payments: type = entity [DataField.PaymentOperationType]; if (type == null) { break; } id = entity [DataField.PaymentOperationId]; try { type = Enum.ToObject(typeof(OperationType), type); intId = Convert.ToInt64(id); } catch (Exception ex) { ErrorHandling.LogException(ex); break; } if (BusinessDomain.RestrictionTree.GetRestriction("mnuEditPaysPaymentsbtnEdit") != UserRestrictionState.Allowed) { break; } Operation oper = Operation.GetById((OperationType)type, intId); if (oper == null) { break; } using (EditNewPayment dialog = new EditNewPayment(oper)) if (dialog.Run() == ResponseType.Ok) { using (new DbMasterScope(BusinessDomain.DataAccessProvider)) oper.CommitPayments(); } break; case DbTable.PaymentTypes: id = entity [DataField.PaymentTypesId]; try { intId = Convert.ToInt64(id); } catch (Exception ex) { ErrorHandling.LogException(ex); break; } using (EditNewPaymentType dialog = new EditNewPaymentType(PaymentType.GetById(intId))) if (dialog.Run() == ResponseType.Ok) { using (new DbMasterScope(BusinessDomain.DataAccessProvider)) dialog.GetPaymentType().CommitChanges(); } break; case DbTable.PriceRules: break; case DbTable.Registration: break; case DbTable.Store: break; case DbTable.System: break; case DbTable.Transformations: break; case DbTable.Users: EditUser(entity [DataField.UserId]); break; case DbTable.OperationUsers: EditUser(entity [DataField.OperationsUserId]); break; case DbTable.OperationOperators: EditUser(entity [DataField.OperationsOperatorId]); break; case DbTable.UsersGroup: EditUserGroup(entity [DataField.UsersGroupsId]); break; case DbTable.OperationUsersGroup: EditUserGroup(entity [DataField.OperationsUsersGroupsId]); break; case DbTable.OperationOperatorsGroup: EditUserGroup(entity [DataField.OperationsOperatorsGroupsId]); break; case DbTable.UsersSecurity: break; case DbTable.VatGroups: id = entity [DataField.VATGroupId]; try { intId = Convert.ToInt64(id); } catch (Exception ex) { ErrorHandling.LogException(ex); break; } if (BusinessDomain.RestrictionTree.GetRestriction("mnuEditVATGroupsbtnEdit") != UserRestrictionState.Allowed) { return; } using (EditNewVATGroup dialog = new EditNewVATGroup(VATGroup.GetById(intId))) if (dialog.Run() == ResponseType.Ok) { using (new DbMasterScope(BusinessDomain.DataAccessProvider)) dialog.GetVATGroup().CommitChanges(); } break; } }