// To protect from overposting attacks, enable the specific properties you want to bind to, for // more details, see https://aka.ms/RazorPagesCRUD. public async Task <IActionResult> OnPostAsync(string[] selectedCategories) { var newDocument = new Document(); if (selectedCategories != null) { newDocument.DocumentCategories = new List <DocumentCategory>(); foreach (var cat in selectedCategories) { var catToAdd = new DocumentCategory { CategoryID = int.Parse(cat) }; newDocument.DocumentCategories.Add(catToAdd); } } if (await TryUpdateModelAsync <Document>( newDocument, "Document", i => i.Title, i => i.Author, i => i.Price, i => i.PublishingDate, i => i.PublisherID)) { _context.Document.Add(newDocument); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } PopulateAssignedCategoryData(_context, newDocument); return(Page()); }
public async Task <IActionResult> DocumentCategory([FromForm] DocumentTypeViewModel model) { string attachPath = string.Empty; if (model.formFile != null) { string fileName; string message = FileSave.SaveImage(out fileName, "Upload/Attachment/DocumentCategory", model.formFile); if (message == "success") { attachPath = fileName; } } DocumentCategory documentCategory = new DocumentCategory { Id = (int)model.documentcategoryId, documentTypeId = model.documentTypeId, categoryName = model.documentCategoryName, categoryNameBn = model.documentCategoryNameBn, imagePath = attachPath }; await lostAndFoundType.SaveDocumentCategory(documentCategory); return(RedirectToAction(nameof(DocumentCategory))); }
/// <summary> /// Creates new <see cref="Payment"/> according to the document's defaults and attaches it to the parent <see cref="Document"/>. /// </summary> /// <returns>A new <see cref="Payment"/>.</returns> public override Payment CreateNew() { //create new Payment object and attach it to the element Document parent = (Document)this.Parent; Payment payment = new Payment(parent); payment.Order = this.Children.Count + 1; DocumentCategory dc = parent.DocumentType.DocumentCategory; CommercialDocument commercialDocument = this.Parent as CommercialDocument; FinancialDocument financialDocument = this.Parent as FinancialDocument; if (dc == DocumentCategory.Sales || dc == DocumentCategory.SalesCorrection) { payment.Direction = -1; } else if (dc == DocumentCategory.Purchase || dc == DocumentCategory.PurchaseCorrection) { payment.Direction = 1; } else if (dc == DocumentCategory.Financial) { FinancialDirection fdc = parent.DocumentType.FinancialDocumentOptions.FinancialDirection; if (fdc == FinancialDirection.Income) { payment.Direction = 1; } else { payment.Direction = -1; } } //Copy payment contractor from source if exists if (this.PaymentContainingSourceDocument != null && this.PaymentContainingSourceDocument.Payments != null && this.PaymentContainingSourceDocument.Payments.Children.Count >= payment.Order) { Payment sourcePayment = this.PaymentContainingSourceDocument.Payments[payment.Order - 1]; payment.Contractor = sourcePayment.Contractor; payment.ContractorAddressId = sourcePayment.ContractorAddressId; } else if (commercialDocument != null) { payment.Contractor = commercialDocument.Contractor; payment.ContractorAddressId = commercialDocument.ContractorAddressId; } else if (financialDocument != null) { payment.Contractor = financialDocument.Contractor; payment.ContractorAddressId = financialDocument.ContractorAddressId; } //add the attribute to the collection this.Children.Add(payment); return(payment); }
protected override void ShowObjectInformation() { item = DocumentCategoryServices.GetById(IntId); ViewState["CurrentObject"] = item; TenLoaiVanBan.Text = item.DocumentCategoryName; ThuTuHienThi.Text = item.DisplayOrder.ToString(); }
private static FinancialDirection GetFinancialDirectionForPayment(CommercialDocument document, Payment payment) { DocumentCategory category = document.DocumentType.DocumentCategory; if (category == DocumentCategory.Sales || category == DocumentCategory.SalesCorrection) { if (payment.Amount > 0) { return(FinancialDirection.Income); } else { return(FinancialDirection.Outcome); } } else if (category == DocumentCategory.Purchase || category == DocumentCategory.PurchaseCorrection) { if (payment.Amount > 0) { return(FinancialDirection.Outcome); } else { return(FinancialDirection.Income); } } throw new InvalidOperationException("Unknown financial direction to choose"); }
protected override void UpdateObject() { item = (DocumentCategory)ViewState["CurrentObject"]; item.DocumentCategoryName = TenLoaiVanBan.Text.Trim(); item.DisplayOrder = ThuTuHienThi.Text.ToInteger(); DocumentCategoryServices.Update(item); }
protected override void CreateNewObject() { item = new DocumentCategory(); item.DocumentCategoryName = TenLoaiVanBan.Text.Trim(); item.DisplayOrder = ThuTuHienThi.Text.ToInteger(); DocumentCategoryServices.Create(item); }
// GET: /DocumentCategoryMaster/Create public ActionResult Create() { DocumentCategory vm = new DocumentCategory(); vm.IsActive = true; return(View("Create", vm)); }
/// <summary> /// Creates new <see cref="CommercialWarehouseRelation"/> and attaches it to the parent <see cref="WarehouseDocumentLine"/> or <see cref="CommercialDocumentLine"/>. /// </summary> /// <returns>A new <see cref="CommercialWarehouseRelation"/>.</returns> public override CommercialWarehouseRelation CreateNew() { //create new CommercialWarehouseRelation object and attach it to the element CommercialWarehouseRelation relation = new CommercialWarehouseRelation(this.Parent); CommercialDocument parent = this.Parent as CommercialDocument; if (parent != null) { DocumentCategory dc = parent.DocumentType.DocumentCategory; if (dc == DocumentCategory.Sales || dc == DocumentCategory.SalesCorrection || dc == DocumentCategory.Purchase || dc == DocumentCategory.PurchaseCorrection) { relation.IsCommercialRelation = true; } if (dc == DocumentCategory.Reservation || dc == DocumentCategory.Order) { relation.IsOrderRelation = true; } if (dc == DocumentCategory.Service) { relation.IsServiceRelation = true; } } //add the CommercialWarehouseRelation to the CommercialWarehouseRelation's collection this.Children.Add(relation); return(relation); }
public async Task<IActionResult> Edit(int id, [Bind("Id,Title,Created,CreatedBy")] DocumentCategory documentCategory) { if (id != documentCategory.Id) { return NotFound(); } if (ModelState.IsValid) { try { _context.Update(documentCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DocumentCategoryExists(documentCategory.Id)) { return NotFound(); } else { throw; } } return RedirectToAction(nameof(Index)); } return View(documentCategory); }
protected void btnSave_Click(object sender, EventArgs e) { DocumentCategory doc; if (Request.QueryString["docid"] != null) { doc = Module.DocumentGetById(Convert.ToInt32(Request.QueryString["docid"])); } else { doc = new DocumentCategory(); } doc.Name = txtServiceName.Text; doc.Note = txtNote.Text; doc.IsCategory = true; if (ddlSuppliers.SelectedIndex > 0) { doc.Parent = Module.DocumentGetById(Convert.ToInt32(ddlSuppliers.SelectedValue)); } else { doc.Parent = null; } if (fileUpload.HasFile) { doc.Url = FileHelper.Upload(fileUpload, "Documents/"); } Module.SaveOrUpdate(doc, UserIdentity); PageRedirect(string.Format("DocumentManage.aspx?NodeId={0}&SectionId={1}&docid={2}", Node.Id, Section.Id, doc.Id)); }
/// <summary> /// Loads and compiles a document with the specified category and context callback. /// </summary> /// <param name="specifier">A string specifying the document to be loaded and compiled.</param> /// <param name="category">An optional category for the requested document.</param> /// <param name="contextCallback">An optional context callback for the requested document.</param> /// <returns>A compiled script that can be executed by multiple V8 script engine instances.</returns> public V8Script CompileDocument(string specifier, DocumentCategory category, DocumentContextCallback contextCallback) { MiscHelpers.VerifyNonBlankArgument(specifier, "specifier", "Invalid document specifier"); var document = DocumentSettings.LoadDocument(null, specifier, category, contextCallback); return(Compile(document.Info, document.GetTextContents())); }
/// <summary> /// Loads and compiles a document with the specified category and context callback, consuming previously generated cache data. /// </summary> /// <param name="specifier">A string specifying the document to be loaded and compiled.</param> /// <param name="category">An optional category for the requested document.</param> /// <param name="contextCallback">An optional context callback for the requested document.</param> /// <param name="cacheKind">The kind of cache data to be consumed.</param> /// <param name="cacheBytes">Cache data for accelerated compilation.</param> /// <param name="cacheAccepted"><c>True</c> if <paramref name="cacheBytes"/> was accepted, <c>false</c> otherwise.</param> /// <returns>A compiled script that can be executed by multiple V8 script engine instances.</returns> /// <remarks> /// To be accepted, the cache data must have been generated for identical script code by /// the same V8 build. /// </remarks> public V8Script CompileDocument(string specifier, DocumentCategory category, DocumentContextCallback contextCallback, V8CacheKind cacheKind, byte[] cacheBytes, out bool cacheAccepted) { MiscHelpers.VerifyNonBlankArgument(specifier, "specifier", "Invalid document specifier"); var document = DocumentSettings.LoadDocument(null, specifier, category, contextCallback); return(Compile(document.Info, document.GetTextContents(), cacheKind, cacheBytes, out cacheAccepted)); }
protected void btnSave_Click(object sender, EventArgs e) { DocumentCategory doc; if (Request.QueryString["docid"] != null) { doc = Module.DocumentGetById(Convert.ToInt32(Request.QueryString["docid"])); } else { doc = new DocumentCategory(); } doc.Name = txtServiceName.Text; doc.Note = txtNote.Text; doc.IsCategory = false; if (ddlSuppliers.SelectedIndex > 0) { doc.Parent = Module.DocumentGetById(Convert.ToInt32(ddlSuppliers.SelectedValue)); } else { doc.Parent = null; } if (fileUpload.HasFile) { doc.Url = FileHelper.Upload(fileUpload, "Documents/"); } Module.SaveOrUpdate(doc, UserIdentity); ClientScript.RegisterStartupScript(this.GetType(), "RefreshParentPage", "<script>window.parent.location.href = window.parent.location.href;</script>"); }
public int UpdateDocumentCategory(DocumentCategoryDTO Record) { DocumentCategory ReturnRecord = DocumentCategoryRequestFormatter.ConvertRespondentInfoFromDTO(Record); var res = _unitOfWork.DocumentCategoryRepository.Update(ReturnRecord); return(res); }
public Response <DocumentCategoryModel> Create(DocumentCategoryCreateModel createModel) { try { using (var unitOfWork = new UnitOfWork()) { var last = unitOfWork.GetRepository <DocumentCategory>().GetAll().OrderByDescending(c => c.CategoryId).FirstOrDefault(); DocumentCategory cate = new DocumentCategory { CategoryId = 1, Description = createModel.Description, Name = createModel.Name, CategoryGroupId = createModel.CategoryGroupId }; if (last != null) { cate.CategoryId = last.CategoryId + 1; } unitOfWork.GetRepository <DocumentCategory>().Add(cate); if (unitOfWork.Save() >= 1) { return(GetById(cate.CategoryId)); } return(new Response <DocumentCategoryModel>(0, "Lưu thông tin không thành công", null)); } } catch (Exception ex) { return(new Response <DocumentCategoryModel>(-1, ex.ToString(), null)); } }
public static DocumentCategoryNamesDto MapToDocumentCategoryNamesDto(DocumentCategory documentCategory) { return(new DocumentCategoryNamesDto() { Id = documentCategory.DocumentCategoryId, Name = documentCategory.DocumentCategoryTitle }); }
public void SetUp() { documentCategory = new DocumentCategory(); validator = new DocumentCategoryValidator(); results = new ValidationResult(); documentCategory = MockDocumentCategory.Get(); }
public ActionResult DocumentCategory(DocumentCategory category) { /* Categories with Parent Categories */ var data = new DocumentCategoryViewModel(); data.Categories = category.ChildDocumentCategories; data.Documents = category.Documents; return(View("DocumentCategory", data)); }
public async Task<IActionResult> Create([Bind("Id,Title")] DocumentCategory documentCategory) { if (ModelState.IsValid) { _context.Add(documentCategory); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(documentCategory); }
public static DocumentCategoryDTO DocumentCategoryDbToDTO(DocumentCategory ModelData) { DocumentCategoryDTO Record = new DocumentCategoryDTO { CatId = ModelData.CatId, CatTitle = ModelData.CatTitle, }; return(Record); }
public void DeleteDocumentCategory() { DocumentCategory toDelete1 = ctx.DocumentCategorySet.FirstOrDefault(p => p.Title == "Cat1"); repo.Delete(toDelete1); repo.Save(); Assert.IsNull(ctx.DocumentCategorySet.FirstOrDefault(p => p.Title == "Cat1")); Assert.IsNotNull(ctx.DocumentSet.FirstOrDefault(p => p.Title == "Doc1")); }
// GET: /ProductMaster/Edit/5 public ActionResult Edit(int id) { DocumentCategory pt = _DocumentCategoryService.Find(id); if (pt == null) { return(HttpNotFound()); } return(View("Create", pt)); }
public ActionResult Create([Bind(Include = "DocumentCategoryId,Description")] DocumentCategory documentCategory) { if (ModelState.IsValid) { _documentCategoryService.CreateDocumentCategory(documentCategory); _documentCategoryService.SaveDocumentCategory(); return(RedirectToAction("Index")); } return(View(documentCategory)); }
// // GET: /Admin/DocumentCategory/ public ActionResult Index() { var dataList = new ListViewModel(); Breadcrumbs.Current.AddBreadcrumb(dataList.BreadcrumbLevel, dataList.Title); Util.SetReturnPage(dataList.BreadcrumbLevel); dataList.PageLoad(); dataList.DocumentCategoryHierarchy = DocumentCategory.GetDocumentCategoryHierarchy(); //this is only called by the admin return(View("DocumentCategoryList", dataList)); }
public ActionResult CategoryDelete(int categoryId, string description, int companyId, int userId) { var res = DocumentCategory.Delete(categoryId, companyId); if (res.Success) { Session["Company"] = new Company(companyId); } return(res); }
// // GET: /DocumentCategory/ //[SiteCustom.SiteOutputCache] public ActionResult ByPageID(int pageID) { DocumentCategory category = DocumentCategory.LoadByPageID(pageID); var data = new ViewModel(category); if (category == null) { throw new Beweb.BadUrlException("Category not found with Page ID of [" + pageID + "]"); } return(View("DocumentCategory", data)); }
public static DocumentCategoryDto MapToDtoDocument(DocumentCategory documentCategory) { return(new DocumentCategoryDto() { DocumentCategoryId = documentCategory.DocumentCategoryId, DocumentCategoryTitle = documentCategory.DocumentCategoryTitle, IsDeleted = documentCategory.IsDeleted, DateCreated = documentCategory.DateCreated, DateModified = documentCategory.DateModified, CustomerId = documentCategory.CustomerId }); }
public DocumentCategory Insert(DocumentCategory documentCategory) { try { documentCategory = documentCategoryRepository.Add(documentCategory); } catch (System.Exception) { throw; } return(documentCategory); }
public ActionResult Create([Bind(Include = "CatId,CatTitle")] DocumentCategory documentCategory) { if (ModelState.IsValid) { db.DocumentCategories.Add(documentCategory); db.SaveChanges(); Session["Success"] = "Document Category Created Succesfully"; return(RedirectToAction("Index")); } return(View("DocumentCategory/Create")); }
private void CreateDocumentCategory() { var category = new DocumentCategory { Name = "Field", Description = "pictures of fields" }; var category2 = new DocumentCategory { Name = "People", Description = "pictures of people" }; _repository.Save(category); _repository.Save(category2); }
public PartialViewResult OpenDocumentSubCategoryEditPopup(int idDocumentCategoryParent, int? idDocumentCategory = null) { var documentCategory = new DocumentCategory() { DocumentCategory2 = DocumentCategoryBL.GetById(idDocumentCategoryParent) }; if (idDocumentCategory.HasValue) { documentCategory = DocumentCategoryBL.GetById(idDocumentCategory.Value); } return PartialView("DocumentSubCategoryEditFormPartial", documentCategory); }
public PartialViewResult OpenDocumentCategoryPopup(int? idDocumentCategory = null) { var documentCategory = new DocumentCategory(); if (idDocumentCategory.HasValue) { documentCategory = DocumentCategoryBL.GetById(idDocumentCategory.Value); } return PartialView("DocumentCategoryFormPartial", documentCategory); }
public ActionResult DeleteSubCategory(int id, int? idDocumentParent) { try { /* 1 - DELETE SUB CATEGORY */ DocumentCategoryBL.DeleteDocumentCategory(id); /* 2 - GET LIST */ var documentCategory = new DocumentCategory(); if (idDocumentParent.HasValue ) { documentCategory = DocumentCategoryBL.GetById(idDocumentParent.Value); } return PartialView("DocumentSubCategoryGridPartial", documentCategory.DocumentCategory1.Where(x =>!x.IsDeleted).ToList()); } catch (Exception ex) { return Content("KO:" + ex.Message); } }
public ActionResult SaveDocumentCategory(DocumentCategoryViewModel postedDocumentCategoryVm) { try { DocumentCategory postedDocumentCategory = postedDocumentCategoryVm.ToEntity(); int idDocumentCategory = 0; if (!string.IsNullOrEmpty(postedDocumentCategory.Label)) { var docCateg = new DocumentCategory() { Label = postedDocumentCategory.Label, idFirmInstitution = SessionManager.GetFirmInstitutionSession().idFirmInstitution, IdDocumentCategoryParent = postedDocumentCategory.IdDocumentCategoryParent, DateCreated = DateTime.Now, IsMandatory = postedDocumentCategory.IsMandatory, IsDocumentDefault = postedDocumentCategory.IsMandatory ? postedDocumentCategory.IsMandatory : postedDocumentCategory.IsDocumentDefault, IsRenseignerDateExp = postedDocumentCategory.IsRenseignerDateExp }; DocumentCategoryBL.AddDocumentCategory(docCateg); idDocumentCategory = docCateg.idDocumentCategory; } var documentCategory = new DocumentCategory(); var lst = new List<DocumentCategory>(); /* create sub document category */ if (postedDocumentCategory.IdDocumentCategoryParent.HasValue && postedDocumentCategory.IdDocumentCategoryParent.Value > 0) { documentCategory = DocumentCategoryBL.GetById(postedDocumentCategory.IdDocumentCategoryParent.Value); if (documentCategory.DocumentCategory1 != null) { lst = documentCategory.DocumentCategory1.Where(x => !x.IsDeleted).ToList(); } return PartialView("DocumentSubCategoryGridPartial", lst); } return PartialView("MainPartialGrid", GetDocCategory()); } catch (Exception ex) { // return Content(LanguageData.GetContent("Rubric_error") + ex.Message); return Content("KO:" + LanguageData.GetContent("Rubric_error")); } }
public ActionResult SaveEditDocumentCategory(DocumentCategoryViewModel postedDocumentCategoryVm) { try { DocumentCategory postedDocumentCategory = postedDocumentCategoryVm.ToEntity(); if (postedDocumentCategory.idDocumentCategory > 0) { var docCateg = DocumentCategoryBL.GetById(postedDocumentCategory.idDocumentCategory); //docCateg. if (docCateg != null) { docCateg.Label = postedDocumentCategory.Label; docCateg.IsMandatory = postedDocumentCategory.IsMandatory; docCateg.IsDocumentDefault = postedDocumentCategory.IsMandatory ? postedDocumentCategory.IsMandatory : postedDocumentCategory.IsDocumentDefault; docCateg.IsRenseignerDateExp = postedDocumentCategory.IsRenseignerDateExp; DocumentCategoryBL.UpdateDocumentCategory(docCateg); } var documentCategory = new DocumentCategory(); var lst = new List<DocumentCategory>(); /* Edit sub document category */ if (postedDocumentCategory.IdDocumentCategoryParent.HasValue && postedDocumentCategory.IdDocumentCategoryParent.Value > 0) { documentCategory = DocumentCategoryBL.GetById(postedDocumentCategory.IdDocumentCategoryParent.Value); if (documentCategory.DocumentCategory1 != null) { lst = documentCategory.DocumentCategory1.ToList(); } return PartialView("DocumentSubCategoryGridPartial", lst); } /* Edit main document category */ return PartialView("MainPartialGrid", GetDocCategory()); } } catch (Exception ex) { // return Content(LanguageData.GetContent("Rubric_error") + ex.Message); return Content("KO:" + LanguageData.GetContent("Rubric_error")); } return PartialView("DocumentSubCategoryGridPartial", new List<DocumentCategory>()); }