Пример #1
0
		public DocumentTypesViewModel()
		{
			Title = "Документы";
			AddCommand = new RelayCommand(OnAdd, CanAdd);
			EditCommand = new RelayCommand(OnEdit, CanEdit);
			RemoveCommand = new RelayCommand(OnRemove, CanRemove);

			Organisations = new List<DocumentTypeViewModel>();
			var organisations = OrganisationHelper.GetByCurrentUser();
			if (organisations == null)
				return;

			foreach (var organisation in organisations)
			{
				var organisationViewModel = new DocumentTypeViewModel(organisation);
				Organisations.Add(organisationViewModel);

				var documentTypes = DocumentTypeHelper.GetByOrganisation(organisation.UID);
				foreach (var documentType in documentTypes)
				{
					if (documentType.OrganisationUID == organisation.UID)
					{
						var documentTypeViewModel = new DocumentTypeViewModel(organisation, documentType);
						organisationViewModel.AddChild(documentTypeViewModel);
					}
				}
			}
			OnPropertyChanged(() => Organisations);
			SelectedDocumentType = Organisations.FirstOrDefault();
		}
Пример #2
0
        public async Task <IActionResult> Index([FromForm] DocumentTypeViewModel model)
        {
            string attachPath = string.Empty;

            if (model.formFile != null)
            {
                string fileName;
                string message = FileSave.SaveImage(out fileName, "Upload/Attachment/DocumentType", model.formFile);

                if (message == "success")
                {
                    attachPath = fileName;
                }
            }
            DocumentType documentType = new DocumentType
            {
                Id = (int)model.documentTypeId,
                documentTypeName   = model.documentTypeName,
                documentTypeNameBn = model.documentTypeNameBn,
                shortOrder         = model.shortOrder,
                imagePath          = attachPath
            };
            await lostAndFoundType.SaveDocumentType(documentType);

            return(RedirectToAction(nameof(Index)));
        }
Пример #3
0
        public async Task <IActionResult> ComputerAccessoriesBrand([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;
                }
            }
            ComputerAccessoriesBrand computerAccessoriesBrand = new ComputerAccessoriesBrand
            {
                Id          = (int)model.documentcategoryId,
                brandName   = model.documentCategoryName,
                brandNameBn = model.documentCategoryNameBn,
                imagePath   = attachPath
            };
            await lostAndFoundType.SaveComputerAccessoriesBrand(computerAccessoriesBrand);

            return(RedirectToAction(nameof(ComputerAccessoriesBrand)));
        }
Пример #4
0
        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)));
        }
Пример #5
0
        public ActionResult Edit(DocumentTypeViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (Request["Submit"] == "Save")
                {
                    var DocumentType = DocumentTypeRepository.GetDocumentTypeById(model.Id);
                    AutoMapper.Mapper.Map(model, DocumentType);
                    DocumentType.ModifiedUserId = WebSecurity.CurrentUserId;
                    DocumentType.ModifiedDate   = DateTime.Now;
                    DocumentTypeRepository.UpdateDocumentType(DocumentType);

                    TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.UpdateSuccess;
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }

            return(View(model));

            //if (Request.UrlReferrer != null)
            //    return Redirect(Request.UrlReferrer.AbsoluteUri);
            //return RedirectToAction("Index");
        }
Пример #6
0
        public JsonResult UpdateRequest(DocumentTypeViewModel obj)
        {
            try
            {
                var docExists = UnitOfWorkExists.DocumentTypeRepository.Get(x => x.DocumentId == obj.DocumentId).ToList();
                var doc       = new DocumentType()
                {
                    DocumentId          = obj.DocumentId,
                    DocumentName        = new GenericMethods().ConvertToTitleCase(obj.DocumentName),
                    DocumentDescription = new GenericMethods().ConvertToSingleUpperCase(obj.DocumentDescription),
                    IsActive            = obj.IsActive,
                    CreatedDate         = docExists[0].CreatedDate,
                    CreatedBy           = docExists[0].CreatedBy,
                    ModifiedBy          = Convert.ToInt32(TempData.Peek("UserId")),
                    ModifiedDate        = DateTime.Now,
                    DocumentCategoryID  = obj.DocumentCategoryID,
                    IsExpiryRequired    = obj.IsExpiryRequired,
                    IsMandatory         = obj.IsMandatory
                };
                UnitOfWork.DocumentTypeRepository.Update(doc);
                UnitOfWork.Save();

                return(Json(new { success = true, responseText = "Document details updated successfully." }));
            }
            catch (Exception ex)
            {
                _logger.LogError(ex.ToString());
                return(Json(new { success = false, responseText = "Something went wrong." }));
            }
        }
Пример #7
0
        public async Task <IActionResult> DocumentCategoryAccessories([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;
                }
            }
            DocumentCategoryAccessories documentCategory = new DocumentCategoryAccessories
            {
                Id                = (int)model.documentcategoryId,
                documentTypeId    = model.documentTypeId,
                accessoriesName   = model.documentCategoryName,
                accessoriesNameBn = model.documentCategoryNameBn,
                imagePath         = attachPath,
                shortOrder        = model.shortOrder
            };
            await lostAndFoundType.SaveDocumentCategoryAccessories(documentCategory);

            return(RedirectToAction("DocumentCategoryAccessories", new RouteValueDictionary(
                                        new { controller = "MasterInformation", action = "DocumentCategoryAccessories", Id = model.documentTypeId })));
        }
Пример #8
0
        public ActionResult DocumentTypeSelectList(string required)
        {
            ViewBag.IsRequired = required;
            DocumentTypeViewModel documentTypeVM = new DocumentTypeViewModel();

            documentTypeVM.DocumentTypeSelectList = _documentTypeBusiness.GetDocumentTypeSelectList();
            return(PartialView("_DocumentTypeSelectList", documentTypeVM));
        }
Пример #9
0
        public ActionResult SaveAddDocumentType(DocumentTypeViewModel model)
        {
            if (model != null)
            {
                model.SaveDocumentType(model);
            }

            return(Json(new { success = true }));
        }
        public void Delete(DocumentTypeViewModel model)
        {
            var item = _repository.FindById(model.Id);

            if (item != null)
            {
                _repository.Delete(item);
            }
        }
Пример #11
0
        public async Task <IActionResult> Edit(DocumentTypeViewModel model)
        {
            var result = await _documentTypeService.EditDocumentTypeAsync(model);


            return(RedirectToAction("Edit", new { id = result.Result.Id }));

            //return View(result.Result);
        }
        /// <summary>
        /// For Delete Record
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        public async Task <ActionResult> Delete(DocumentTypeViewModel collection)
        {
            collection.ModifiedDate = DateTime.Now;
            var stringContent = new StringContent(JsonConvert.SerializeObject(collection).ToString(), Encoding.UTF8, "application/json");
            var status        = await service.Delete(stringContent);

            return(new JsonResult {
                Data = status, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
Пример #13
0
        /// <summary>
        /// save document type async
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual async Task <ResultModel> SaveDocumentTypeAsync(DocumentTypeViewModel model)
        {
            //model.Code = code;
            await _context.DocumentTypes.AddAsync(model);

            var dbResult = await _context.PushAsync();

            dbResult.Result = model;
            return(dbResult);
        }
Пример #14
0
        public async Task <IActionResult> Index()
        {
            DocumentTypeViewModel model = new DocumentTypeViewModel
            {
                documentTypes = await lostAndFoundType.GetDocumentTypes(),
                fLang         = _lang.PerseLang("MasterData/DocumentTypeEN.json", "MasterData/DocumentTypeBN.json", Request.Cookies["lang"]),
            };

            return(View(model));
        }
Пример #15
0
        public async Task <IActionResult> ComputerAccessoriesBrand()
        {
            DocumentTypeViewModel model = new DocumentTypeViewModel
            {
                computerAccessoriesBrands = await lostAndFoundType.GetAllComputerAccessoriesBrand(),
                fLang = _lang.PerseLang("MasterData/DocumentTypeEN.json", "MasterData/DocumentTypeBN.json", Request.Cookies["lang"]),
            };

            return(View(model));
        }
        public async Task <ActionResult <DocumentTypeViewModel> > Post(DocumentTypeViewModel documentType)
        {
            var response = await _documentTypeService.Create(documentType.ToModel());

            if (response != BusinessLogic.Enums.StatusCode.Created)
            {
                _logger.LogError($"DocumentType {documentType.Name} not Created.");
            }

            return(response == BusinessLogic.Enums.StatusCode.Created
                ? (ActionResult <DocumentTypeViewModel>)Ok()
                : Conflict());
        }
Пример #17
0
        public async Task <IActionResult> Create(DocumentTypeViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddCommerceError(CommerceErrorKeys.InvalidModel);
                return(View(model));
            }

            var result = await _documentTypeService.SaveDocumentTypeAsync(model);


            return(View(result.Result));
        }
 public ActionResult Delete(DocumentTypeViewModel model)
 {
     try
     {
         service.Delete(model);
         service.Save();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Пример #19
0
        /// <summary>
        /// GetBy Id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <DocumentTypeViewModel> GetById(int id)
        {
            var documentType = new DocumentTypeViewModel();

            using (var client = Common.GetHttpClient())
            {
                var Response = await client.GetAsync(DocumentTypeConstant.DOCUMENTTYPE_API_GET_BY_ID + "id=" + id);

                if (Response.IsSuccessStatusCode)
                {
                    return(JsonConvert.DeserializeObject <DocumentTypeViewModel>(Response.Content.ReadAsStringAsync().Result));
                }
                return(null);
            }
        }
Пример #20
0
        public async Task <IActionResult> DocumentCategoryAccessories(int id)
        {
            var documents = await lostAndFoundType.GetDocumentTypesById(id);

            DocumentTypeViewModel model = new DocumentTypeViewModel
            {
                documentTypeId              = id,
                documentTypeName            = documents.documentTypeName,
                documentTypeNameBn          = documents.documentTypeNameBn,
                documentCategoryAccessories = await lostAndFoundType.GetDocumentCategoryAccessoriesByDocumentTypeId(id),
                fLang = _lang.PerseLang("MasterData/DocumentTypeEN.json", "MasterData/DocumentTypeBN.json", Request.Cookies["lang"]),
            };

            return(View(model));
        }
        public async Task <ActionResult> Edit(DocumentTypeViewModel collection)
        {
            try
            {
                collection.ModifiedDate = DateTime.Now;
                var stringContent = new StringContent(JsonConvert.SerializeObject(collection).ToString(), Encoding.UTF8, "application/json");
                var status        = await service.Update(stringContent);

                return(new JsonResult {
                    Data = new { status = status }
                });
            }
            catch
            {
                return(View());
            }
        }
        public async Task <JsonResult> Index(string id)
        {
            int docCatId;

            int.TryParse(id, out docCatId);

            DocumentTypeViewModel collection = new DocumentTypeViewModel();
            var draw = HttpContext.Request.Form["draw"].FirstOrDefault();
            // Skiping number of Rows count
            var start = Request.Form["start"];
            // Paging Length 10,20
            var length = Request.Form["length"];
            // Sort Column Name
            var sortColumn = Request.Form["columns[" + Request.Form["order[0][column]"].FirstOrDefault() + "][name]"];
            // Sort Column Direction ( asc ,desc)
            var sortColumnDirection = Request.Form["order[0][dir]"];
            // Search Value from (Search box)
            // var searchValue = Request.Form["search[value]"];

            //Paging Size (10,20,50,100)
            int pageSize = length != null?Convert.ToInt32(length) : 0;

            int skip = start != null?Convert.ToInt32(start) : 0;

            int recordsTotal = 0;

            collection.PageNo             = skip;
            collection.PageSize           = pageSize;
            collection.SortOrder          = sortColumnDirection;
            collection.SortColumn         = sortColumn;
            collection.DocumentCategoryID = docCatId;
            var stringContent = new StringContent(JsonConvert.SerializeObject(collection).ToString(), Encoding.UTF8, "application/json");
            var list          = await service.GetAllMDocumenTypeData(stringContent);

            ///Updated by jiya 10--Aug-2019
            ///Cause: Code breaking while data not available.
            foreach (var item in list)
            {
                recordsTotal = list[0].RowCount;
                item.DocumentCategoryName = item.MasterTable?.Name;
            }
            var data = list.Skip(skip).Take(pageSize).ToList();

            return(Json(new { draw = draw, recordsFiltered = recordsTotal, recordsTotal = recordsTotal, data = list }));
        }
        public ActionResult Edit(DocumentTypeViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    service.Update(model);
                    service.Save();
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }
            catch
            {
                return(View());
            }
        }
Пример #24
0
        public ActionResult Create(DocumentTypeViewModel model)
        {
            if (ModelState.IsValid)
            {
                var DocumentType = new DocumentType();
                AutoMapper.Mapper.Map(model, DocumentType);
                DocumentType.IsDeleted      = false;
                DocumentType.CreatedUserId  = WebSecurity.CurrentUserId;
                DocumentType.ModifiedUserId = WebSecurity.CurrentUserId;
                DocumentType.AssignedUserId = WebSecurity.CurrentUserId;
                DocumentType.CreatedDate    = DateTime.Now;
                DocumentType.ModifiedDate   = DateTime.Now;
                DocumentTypeRepository.InsertDocumentType(DocumentType);

                TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
                return(RedirectToAction("Index"));
            }
            return(View(model));
        }
        public async Task <JsonResult> Create(DocumentTypeViewModel collection)
        {
            try
            {
                collection.CreatedBy   = 1;
                collection.CreatedDate = DateTime.Now;
                var stringContent = new StringContent(JsonConvert.SerializeObject(collection).ToString(), Encoding.UTF8, "application/json");
                var status        = await service.Save(stringContent);

                return(new JsonResult {
                    Data = new { status = status }
                });
            }
            catch (Exception ex)
            {
                return(new JsonResult {
                    Data = new { status = false }
                });
            }
        }
Пример #26
0
 public JsonResult IsDocumentNameExists(DocumentTypeViewModel obj)
 {
     try
     {
         var  documents = UnitOfWork.DocumentTypeRepository.Get();
         bool has       = documents.ToList().Any(x => x.DocumentName.ToLower() == obj.DocumentName.ToLower() && x.DocumentCategoryID == obj.DocumentCategoryID);
         if (has)
         {
             return(Json(new { value = true, responseText = "Document name exists" }));
         }
         else
         {
             return(Json(new { value = false, responseText = "Document name is not exists" }));
         }
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.ToString());
         return(Json(new { value = true, responseText = "Document name exists" }));
     }
 }
Пример #27
0
		void OnAdd()
		{
			var documentTypeDetailsViewModel = new DocumentTypeDetailsViewModel(SelectedDocumentType.Organisation.UID);
			if (DialogService.ShowModalWindow(documentTypeDetailsViewModel))
			{
				if (DocumentTypeHelper.Add(documentTypeDetailsViewModel.TimeTrackDocumentType))
				{
					var documentViewModel = new DocumentTypeViewModel(SelectedDocumentType.Organisation, documentTypeDetailsViewModel.TimeTrackDocumentType);

					DocumentTypeViewModel OrganisationViewModel = SelectedDocumentType;
					if (!OrganisationViewModel.IsOrganisation)
						OrganisationViewModel = SelectedDocumentType.Parent;

					if (OrganisationViewModel == null || OrganisationViewModel.Organisation == null)
						return;

					OrganisationViewModel.AddChild(documentViewModel);
					SelectedDocumentType = documentViewModel;
				}
			}
		}
Пример #28
0
        public ActionResult Index()
        {
            var documentTypeViewModel = new DocumentTypeViewModel();
            var documentTypes         = _documentTypeService.GetDocumentTypes();
            var documentTypesDetails  = Mapper.Map <IEnumerable <DocumentType>, IEnumerable <DocumentTypeFormModel> >(documentTypes);
            var indicatorGroups       = _indicatorGroupService.GetIndicatorGroupWithDocumentType();

            foreach (var documentType in documentTypesDetails)
            {
                documentType.IndicatorGroups = indicatorGroups.Where(ct => ct.DocumentType != null &&
                                                                     ct.DocumentType.DocumentTypeID == documentType.DocumentTypeID)
                                               .Select(ct => new SelectListItem
                {
                    Value    = ct.IndicatorGroupID.ToString(),
                    Text     = ct.Name,
                    Selected = ct.DocumentType == null ? false : ct.DocumentType.DocumentTypeID == documentType.DocumentTypeID
                });
            }
            documentTypeViewModel.DocumentTypes        = documentTypesDetails;
            documentTypeViewModel.IndicatorGroupSelect = Mapper.Map <IEnumerable <IndicatorGroup>, IEnumerable <IndicatorGroupSelect> >
                                                             (indicatorGroups.Where(ct => ct.DocumentType == null)).ToList();
            return(View(documentTypeViewModel));
        }
Пример #29
0
        public ActionResult Edit(int?Id)
        {
            var DocumentType = DocumentTypeRepository.GetDocumentTypeById(Id.Value);

            if (DocumentType != null && DocumentType.IsDeleted != true)
            {
                var model = new DocumentTypeViewModel();
                AutoMapper.Mapper.Map(DocumentType, model);

                //if (model.CreatedUserId != Erp.BackOffice.Helpers.Common.CurrentUser.Id && Erp.BackOffice.Helpers.Common.CurrentUser.UserTypeId != 1)
                //{
                //    TempData["FailedMessage"] = "NotOwner";
                //    return RedirectToAction("Index");
                //}

                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }
Пример #30
0
        public ViewResult Create()
        {
            var model = new DocumentTypeViewModel();

            return(View(model));
        }
Пример #31
0
        public ActionResult DocumentType()
        {
            DocumentTypeViewModel model = new DocumentTypeViewModel();

            return(PartialView("_DocumentTypeAdd", model));
        }
 public static DocumentType ToModel(this DocumentTypeViewModel model) => Mapper.Map <DocumentType>(model);