public ActionResult Edit(Guid id)
        {
            var contractModificationModel = new ContractModificationViewModel();

            if (id != Guid.Empty)
            {
                var taskModificationEntity = _contractModificationService.GetDetailById(id);
                contractModificationModel = _mapper.Map <ContractModificationViewModel>(taskModificationEntity);

                contractModificationModel.ContractNumber =
                    _contractService.GetDetailsForProjectByContractId(contractModificationModel.ContractGuid).ContractNumber;

                contractModificationModel.ProjectNumber =
                    _contractService.GetDetailById(contractModificationModel.ContractGuid).BasicContractInfo.ProjectNumber;

                contractModificationModel.keyValuePairs = new Dictionary <string, string>();
                var contractModification = _resourceAttributeService.GetByResource(ResourceType.ContractModification.ToString());
                if (contractModification != null)
                {
                    var modificationType = contractModification.FirstOrDefault(x => x.Name.ToUpper() == "MODIFICATIONTYPE");
                    if (modificationType != null)
                    {
                        var resourcevalue = _resourceAttributeValueService.GetResourceAttributeOptionsByResourceAttributeGuid(modificationType.ResourceAttributeGuid);
                        if (resourcevalue != null)
                        {
                            contractModificationModel.keyValuePairs = resourcevalue.ToDictionary(x => x.Value, x => x.Name);
                        }
                    }
                }

                var currentUser = _userService.GetUserByUserGuid(UserHelper.CurrentUserGuid(HttpContext));
                var users       = Models.ObjectMapper <User, UserViewModel> .Map(currentUser);

                ViewBag.UpdatedBy   = users.Displayname;
                ViewBag.UpdatedOn   = CurrentDateTimeHelper.GetCurrentDateTime().ToString("MM/dd/yyyy");
                ViewBag.ResourceId  = contractModificationModel.ContractModificationGuid;
                ViewBag.Resourcekey = EnumGlobal.ResourceType.TaskOrderModification.ToString();
            }
            try
            {
                return(PartialView(contractModificationModel));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
                return(View(contractModificationModel));
            }
        }
        public IActionResult UploadSaveFile(Guid resourceId, string resourceKey, string uploadPath, string[] fileInfo, Guid parentid, string contractResourceFileKey, Guid ContentResourceGuid)
        {
            try
            {
                //Avoiding Kendo Uploader's default call
                if (resourceId == Guid.Empty || string.IsNullOrEmpty(uploadPath))
                {
                    return(Ok(true));
                }

                //If new file/s have been uploaded
                if (Request.Form.Files.Count > 0)
                {
                    var files = Request.Form.Files;
                    //foreach (var file in files)
                    for (int i = 0; i < files.Count; i++)
                    {
                        var fileInfoObj = fileInfo[i].Split(',');

                        //save file in folder..

                        var fullPath         = files[i].FileName.Split("\\");
                        var originalFileName = fullPath[fullPath.Length - 1];

                        //var fullPhysicalFilePath = Path.Combine(documentRoot, uploadPath);
                        var fullPhysicalFilePath = string.Concat(documentRoot, uploadPath);

                        var uniqueFileName =
                            _fileService.SaveFile(fullPhysicalFilePath, files[i]);

                        var relativeFilePath = Path.Combine(uploadPath, uniqueFileName);

                        //save file info in database..
                        ContractFileViewModel contractFileViewModel = new ContractFileViewModel();

                        contractFileViewModel.ContractResourceFileGuid = new Guid(fileInfoObj[0]);
                        contractFileViewModel.CreatedOn    = CurrentDateTimeHelper.GetCurrentDateTime();
                        contractFileViewModel.UpdatedOn    = CurrentDateTimeHelper.GetCurrentDateTime();
                        contractFileViewModel.CreatedBy    = UserHelper.CurrentUserGuid(HttpContext);
                        contractFileViewModel.UpdatedBy    = UserHelper.CurrentUserGuid(HttpContext);
                        contractFileViewModel.Description  = WebUtility.UrlDecode(fileInfoObj[1]);
                        contractFileViewModel.MimeType     = files[i].ContentType;
                        contractFileViewModel.ResourceGuid = resourceId;
                        //contractFileViewModel.keys = resourceKey;
                        contractFileViewModel.ParentId             = parentid;
                        contractFileViewModel.UploadFileName       = uniqueFileName;
                        contractFileViewModel.UploadUniqueFileName = uniqueFileName;
                        contractFileViewModel.IsActive             = true;
                        contractFileViewModel.IsDeleted            = false;
                        contractFileViewModel.FilePath             = relativeFilePath;
                        contractFileViewModel.FileSize             = fileInfoObj[4];
                        contractFileViewModel.Isfile              = true;
                        contractFileViewModel.keys                = contractResourceFileKey;
                        contractFileViewModel.ResourceType        = resourceKey;
                        contractFileViewModel.ContentResourceGuid = ContentResourceGuid;

                        if (resourceKey.ToUpper() == EnumGlobal.ResourceType.ContractModification.ToString().ToUpper() || resourceKey.ToUpper() == EnumGlobal.ResourceType.TaskOrderModification.ToString().ToUpper())
                        {
                            var contractGuid         = _contractModificationService.GetDetailById(ContentResourceGuid).ContractGuid;
                            var contractResourceFile = _contractResourceFileService.GetFilePathByResourceIdAndKeys(ContractResourceFileKey.ContractModification.ToString(), contractGuid);
                            contractFileViewModel.ParentId     = contractResourceFile.ContractResourceFileGuid;
                            contractFileViewModel.keys         = ContractResourceFileKey.ContractModification.ToString();
                            contractFileViewModel.ResourceGuid = contractGuid;

                            //contractFileViewModel.ResourceType = resourceKey;
                            //for task order also resourcetype is Contract to show in the tree view from the database..
                            contractFileViewModel.ResourceType = EnumGlobal.ResourceType.Contract.ToString();
                        }
                        else if ((parentid == Guid.Empty || parentid != null) && ContentResourceGuid == Guid.Empty)
                        {
                            if (resourceKey.ToUpper() != EnumGlobal.ResourceType.ContractCloseOut.ToString().ToUpper())
                            {
                                var contractResourceFile = _contractResourceFileService.GetFilePathByResourceIdAndKeys(EnumGlobal.ResourceType.Base.ToString(), resourceId);
                                contractFileViewModel.ParentId = contractResourceFile.ContractResourceFileGuid;
                                contractFileViewModel.keys     = EnumGlobal.ResourceType.Base.ToString();
                                //contractFileViewModel.ResourceType = resourceKey;
                                //for task order also resourcetype is Contract to show in the tree view from the database..
                                contractFileViewModel.ResourceType = EnumGlobal.ResourceType.Contract.ToString();
                            }
                        }

                        if (resourceKey.ToUpper() == EnumGlobal.ResourceType.ContractCloseOut.ToString().ToUpper())
                        {
                            contractFileViewModel.ResourceType = EnumGlobal.ResourceType.Contract.ToString();
                        }

                        var fileEntity = _mapper.Map <ContractResourceFile>(contractFileViewModel);

                        _contractRefactorService.InsertContractFile(fileEntity);

                        //auditlog..
                        AuditLogForUploadDownload(fileEntity, CrudTypeForAdditionalLogMessage.Uploaded.ToString());
                    }
                }

                //If existing file/s description have been changed
                if (fileInfo.Length > Request.Form.Files.Count)
                {
                    for (int i = Request.Form.Files.Count; i <= fileInfo.Length - 1; i++)
                    {
                        var fileInfoObj = fileInfo[i].Split(',');

                        var fileById = _contractRefactorService.GetFilesByContractFileGuid(new Guid(fileInfoObj[0]));
                        if (fileById != null)
                        {
                            fileById.Description = WebUtility.UrlDecode(fileInfoObj[1]);
                            _contractRefactorService.UpdateFile(fileById);
                        }
                    }
                }

                return(Ok(true));
            }
            catch (Exception ex)
            {
                return(BadRequestFormatter.BadRequest(this, ex));
            }
        }