Esempio n. 1
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));
        }
Esempio n. 2
0
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity"), HttpPost, ValidateAntiForgeryToken]//ValidateAntiForgeryTokenOnAllPosts
        public ActionResult SaveDCRAdminForm(DCRAdminDetailSection model)
        {
            ActionStatus status = new ActionStatus();

            if (model != null)
            {
                if (string.IsNullOrEmpty(model.OldDCRNo))
                {
                    ModelState.Remove("DesignEngineer");
                    ModelState.Remove("DDHODDISPOSAL");
                    ModelState.Remove("IfNotConsidered");
                    ModelState.Remove("ReworkComments");
                    ModelState.Remove("MarketingApprovalRequired");
                }


                if (this.ValidateModelState(model))
                {
                    if (model.ActionStatus == ButtonActionStatus.NextApproval)
                    {
                        if (model.BusinessUnit.Contains("(CP)"))
                        {
                            model.DCRInchargeNavigator = string.Empty;
                            model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.DCRINCHARGENAVIGATOR).Status = ApproverStatus.NOTREQUIRED;
                        }
                        else
                        {
                            model.DCRInchargeNavigator = model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.DCRINCHARGENAVIGATOR).Approver;
                            model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.DCRPROCESSINCHARGE).Approver = string.Empty;
                        }
                    }
                    if (model.ApproversList != null)
                    {
                        if (model.QAIComment == null)
                        {
                            model.QAIComment = " ";
                        }
                        model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.QAINCHARGE).Comments = model.QAIComment;
                        if (model.DCRProcessIComment == null)
                        {
                            model.DCRProcessIComment = " ";
                        }
                        model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.DCRPROCESSINCHARGE).Comments = model.DCRProcessIComment;
                        if (model.DCRInchargeNavigatorComment == null)
                        {
                            model.DCRInchargeNavigatorComment = " ";
                        }
                        model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.DCRINCHARGENAVIGATOR).Comments = model.DCRInchargeNavigatorComment;
                        if (model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.DESIGNENGINEERINCHARGE) != null)
                        {
                            if (model.DesignEngineerIComment == null)
                            {
                                model.DesignEngineerIComment = " ";
                            }
                            model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.DESIGNENGINEERINCHARGE).Comments = model.DesignEngineerIComment;
                        }
                        if (model.SCMIComment == null)
                        {
                            model.SCMIComment = " ";
                        }
                        model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.SCMINCHARGE).Comments = model.SCMIComment;
                        if (model.LUMIComment == null)
                        {
                            model.LUMIComment = " ";
                        }
                        model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.LUMMARKETINGINCHARGE).Comments = model.LUMIComment;
                        if (model.KAPIComment == null)
                        {
                            model.KAPIComment = " ";
                        }
                        model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.KAPMARKETINGINCHARGE).Comments = model.KAPIComment;
                        if (model.DAPIComment == null)
                        {
                            model.DAPIComment = " ";
                        }
                        model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.DAPMARKETINGINCHARGE).Comments = model.DAPIComment;
                        if (model.FANIComment == null)
                        {
                            model.FANIComment = " ";
                        }
                        model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.FANSMARKETINGINCHARGE).Comments = model.FANIComment;
                        if (model.LightingIComment == null)
                        {
                            model.LightingIComment = " ";
                        }
                        model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.LIGHTINGMARKETINGINCHARGE).Comments = model.LightingIComment;
                        if (model.MRMarketingIComment == null)
                        {
                            model.MRMarketingIComment = " ";
                        }
                        model.ApproversList.FirstOrDefault(p => p.Role == DCRRoles.MORPHYRICHARDSMARKETINGINCHARGE).Comments = model.MRMarketingIComment;
                    }

                    ////file Operation
                    model.Files = new List <FileDetails>();
                    model.Files.AddRange(FileListHelper.GenerateFileBytes(model.FNLDesignChangeAttachment));
                    model.Files.AddRange(FileListHelper.GenerateFileBytes(model.FNLExpectedResultsAttachment));
                    model.FNLDesignChangeAttachment    = string.Join(",", FileListHelper.GetFileNames(model.FNLDesignChangeAttachment));
                    model.FNLExpectedResultsAttachment = string.Join(",", FileListHelper.GetFileNames(model.FNLExpectedResultsAttachment));

                    model.Files.AddRange(FileListHelper.GenerateFileBytes(model.FNLDCRAttachment));
                    model.FNLDCRAttachment = string.Join(",", FileListHelper.GetFileNames(model.FNLDCRAttachment));

                    model.Files.AddRange(FileListHelper.GenerateFileBytes(model.FNLDEAttachment));
                    model.FNLDEAttachment = string.Join(",", FileListHelper.GetFileNames(model.FNLDEAttachment));
                    model.Files.AddRange(FileListHelper.GenerateFileBytes(model.FNLQATestReport));
                    model.FNLQATestReport = string.Join(",", FileListHelper.GetFileNames(model.FNLQATestReport));

                    var list = this.GetTempData <List <VendorDCR> >(TempKeys.DCRVendor.ToString() + "_" + GetFormIdFromUrl());
                    model.VendorDCRList = list.ToList <ITrans>();
                    //model.RejectedComment = model.IfNotConsidered + " " + model.CommentsAfterProtoTesting;

                    Dictionary <string, string> objDict = this.GetSaveDataDictionary(this.CurrentUser.UserId, model.ActionStatus.ToString(), model.ButtonCaption);
                    status = this.SaveSection(model, objDict);
                    status = this.GetMessage(status, System.Web.Mvc.Html.ResourceNames.DCR);
                }

                else
                {
                    status.IsSucceed = false;
                    status.Messages  = this.GetErrorMessage(System.Web.Mvc.Html.ResourceNames.DCR);
                }
            }

            return(this.Json(status));
        }