public ActionResult Delete(int?customerDocumentId, int?masterCustomerId = null)
        {
            CustomerDocumentItemModel customerDocumentItemModel = new CustomerDocumentItemModel()
            {
                IsSecurityOperations = this.IsSecurityOperations,
                CustomerDocument     = new CustomerDocumentViewModel(),
                ControllerAction     = "Delete",
                MasterCustomerId     = masterCustomerId
            };

            try
            {
                CustomerDocumentDTO customerDocumentDTO = Application.GetById(customerDocumentItemModel.OperationResult, new object[] { customerDocumentId });
                if (customerDocumentDTO != null)
                {
                    customerDocumentItemModel.CustomerDocument = new CustomerDocumentViewModel(customerDocumentDTO);
                }
            }
            catch (Exception exception)
            {
                customerDocumentItemModel.OperationResult.ParseException(exception);
            }

            return(View(customerDocumentItemModel));
        }
Пример #2
0
        public ActionResult Delete(CustomerDocumentItemModel customerDocumentItemModel)
        {
            try
            {
                if (Application.Delete(customerDocumentItemModel.OperationResult, (CustomerDocumentDTO)customerDocumentItemModel.CustomerDocument.ToDTO()))
                {
                    return(JsonResultSuccess(new { uri = ReadUrlDictionary() }));
                }
            }
            catch (Exception exception)
            {
                customerDocumentItemModel.OperationResult.ParseException(exception);
            }

            return(JsonResultOperationResult(customerDocumentItemModel.OperationResult));
        }
        public ActionResult Update(CustomerDocumentItemModel customerDocumentItemModel)
        {
            try
            {
                if (ValidateModelState(Application.Repository))
                {
                    if (Application.Update(customerDocumentItemModel.OperationResult, (CustomerDocumentDTO)customerDocumentItemModel.CustomerDocument.ToDTO()))
                    {
                        return(RedirectToUrlDictionary());
                    }
                }
            }
            catch (Exception exception)
            {
                customerDocumentItemModel.OperationResult.ParseException(exception);
            }

            customerDocumentItemModel.IsSecurityOperations = IsSecurityOperations;

            return(View(customerDocumentItemModel));
        }
Пример #4
0
        public ActionResult Create(int?masterCustomerId = null)
        {
            CustomerDocumentItemModel customerDocumentItemModel = new CustomerDocumentItemModel()
            {
                IsSecurityOperations = this.IsSecurityOperations,
                CustomerDocument     = new CustomerDocumentViewModel(),
                ControllerAction     = "Create",
                MasterCustomerId     = masterCustomerId
            };

            try
            {
                IsCreate(customerDocumentItemModel.OperationResult);
            }
            catch (Exception exception)
            {
                customerDocumentItemModel.OperationResult.ParseException(exception);
            }

            return(PartialView(customerDocumentItemModel));
        }
        public ActionResult Delete(CustomerDocumentItemModel customerDocumentItemModel) // !!!
        {
            try
            {
                int        customerDocumentId = customerDocumentItemModel.CustomerDocument.CustomerDocumentId;
                ZFileTypes fileType           = LibraryHelper.GetFileType(customerDocumentItemModel.CustomerDocument.FileAcronym);

                if (Application.Delete(customerDocumentItemModel.OperationResult, (CustomerDocumentDTO)customerDocumentItemModel.CustomerDocument.ToDTO()))
                {
                    IEdmManager edmManager = DependencyResolver.Current.GetService <IEdmManager>();
                    edmManager.DeleteFile("CustomerDocument", customerDocumentId, fileType);

                    return(RedirectToUrlDictionary());
                }
            }
            catch (Exception exception)
            {
                customerDocumentItemModel.OperationResult.ParseException(exception);
            }

            customerDocumentItemModel.IsSecurityOperations = IsSecurityOperations;

            return(View(customerDocumentItemModel));
        }
        public ActionResult Create(CustomerDocumentItemModel customerDocumentItemModel) // !!!
        {
            try
            {
                if (ValidateModelState(Application.Repository))
                {
                    if (customerDocumentItemModel.Upload != null && customerDocumentItemModel.Upload.ContentLength > 0)
                    {
                        ZFileTypes fileType = LibraryHelper.GetFileType(Path.GetExtension(customerDocumentItemModel.Upload.FileName));
                        string     acronym  = LibraryHelper.GetAcronym(fileType);
                        customerDocumentItemModel.CustomerDocument.FileAcronym = acronym;

                        CustomerDocumentDTO customerDocumentDTO = (CustomerDocumentDTO)customerDocumentItemModel.CustomerDocument.ToDTO();

                        if (Application.Create(customerDocumentItemModel.OperationResult, customerDocumentDTO))
                        {
                            byte[] uploadArray = new byte[customerDocumentItemModel.Upload.ContentLength];
                            customerDocumentItemModel.Upload.InputStream.Read(uploadArray, 0, uploadArray.Length);

                            IEdmManager edmManager = DependencyResolver.Current.GetService <IEdmManager>();
                            edmManager.WriteFile("CustomerDocument", customerDocumentDTO.CustomerDocumentId, fileType, uploadArray);

                            return(RedirectToUrlDictionary());
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                customerDocumentItemModel.OperationResult.ParseException(exception);
            }

            customerDocumentItemModel.IsSecurityOperations = IsSecurityOperations;

            return(View(customerDocumentItemModel));
        }