Beispiel #1
0
        public ActionResult DeleteRevisedAppDoc(int index)
        {
            ActionStatus status = new ActionStatus()
            {
                IsSucceed = true
            };
            List <RevisedApplicableDocuments> list = new List <RevisedApplicableDocuments>();

            list = this.GetTempData <List <RevisedApplicableDocuments> >(TempKeys.RevisedApplicableDoc.ToString() + "_" + GetFormIdFromUrl());
            RevisedApplicableDocuments item = list.FirstOrDefault(x => x.Index == index);

            list.RemoveAll(x => x.Index == index);
            if (item != null && item.ID > 0)
            {
                item.ItemAction = ItemActionStatus.DELETED;
                list.Add(item);
            }
            this.SetTempData <List <RevisedApplicableDocuments> >(TempKeys.RevisedApplicableDoc.ToString() + "_" + GetFormIdFromUrl(), list.OrderBy(x => x.Index).ToList());
            status.Messages.Add(this.GetResourceValue("Text_RevisedAppDocDeleted", System.Web.Mvc.Html.ResourceNames.DCN));
            return(this.Json(status, JsonRequestBehavior.AllowGet));
        }
        public ActionResult AddEditRevisedAppDoc(int index = 0)
        {
            List <RevisedApplicableDocuments> list = new List <RevisedApplicableDocuments>();

            list = this.GetTempData <List <RevisedApplicableDocuments> >(TempKeys.RevisedApplicableDoc.ToString() + "_" + GetFormIdFromUrl());
            RevisedApplicableDocuments item = null;

            if (index == 0)
            {
                item = new RevisedApplicableDocuments()
                {
                    Index = 0, RequestDate = DateTime.Now, RequestBy = this.CurrentUser.UserId
                };
            }
            else
            {
                item = list.FirstOrDefault(x => x.Index == index);
                item.FileNameList = item.Files != null && !item.FileNameList.Contains("[{") ? JsonConvert.SerializeObject(item.Files) : item.FileNameList;
            }
            return(this.PartialView("_AddRevisedDoc", item));
        }
Beispiel #3
0
        public ActionResult SaveRevisedAppDoc(RevisedApplicableDocuments model)
        {
            ActionStatus status = new ActionStatus()
            {
                IsSucceed = true
            };

            if (model != null)
            {
                if (ModelState.IsValid)
                {
                    List <RevisedApplicableDocuments> list = new List <RevisedApplicableDocuments>();
                    list = this.GetTempData <List <RevisedApplicableDocuments> >(TempKeys.RevisedApplicableDoc.ToString() + "_" + GetFormIdFromUrl());
                    if (model.Index == 0)
                    {
                        model.Index       = list.Count + 1;
                        model.ItemAction  = ItemActionStatus.NEW;
                        model.RequestDate = !model.RequestDate.HasValue ? DateTime.Now : model.RequestDate.Value;
                    }
                    else
                    {
                        list.RemoveAll(x => x.Index == model.Index);
                    }
                    if (model.ID > 0)
                    {
                        model.ItemAction = ItemActionStatus.UPDATED;
                    }

                    model.Files = new List <FileDetails>();
                    if (!string.IsNullOrEmpty(model.FileNameList))
                    {
                        model.Files.AddRange(JsonConvert.DeserializeObject <List <FileDetails> >(model.FileNameList));
                    }

                    model.Files.ForEach(p =>
                    {
                        if (p.Status == FileStatus.New || p.Status == FileStatus.Delete)
                        {
                            if (p.FileURL.StartsWith(FileListHelper.ApplicatinBaseUrl))
                            {
                                p.FileURL = "~/" + p.FileURL.Replace(FileListHelper.ApplicatinBaseUrl, string.Empty).Trim('/');
                                if (p.FileURL.Contains("/Uploads/") || p.FileURL.Contains("/Sample/"))
                                {
                                    p.FileContent = FileListHelper.DownloadFileBytes(p.FileURL);
                                }
                            }
                        }
                        else
                        {
                            p.FileContent = CommonBusinessLayer.Instance.DownloadFile(p.FileURL, "DCN");
                        }
                    });
                    model.FileNameList = string.Join(",", FileListHelper.GetFileNames(model.FileNameList));

                    list.Add(model);
                    this.SetTempData <List <RevisedApplicableDocuments> >(TempKeys.RevisedApplicableDoc.ToString() + "_" + GetFormIdFromUrl(), list.OrderBy(x => x.Index).ToList());
                    status.Messages.Add(this.GetResourceValue("Text_RevisedAppDocSave", System.Web.Mvc.Html.ResourceNames.DCN));
                    status = this.GetMessage(status, System.Web.Mvc.Html.ResourceNames.DCN);
                }
                else
                {
                    status.IsSucceed = false;
                    status.Messages  = this.GetErrorMessage(System.Web.Mvc.Html.ResourceNames.DCN);
                }
            }
            return(this.Json(status));
        }