Ejemplo n.º 1
0
        /// <summary>
        /// Get LiquorApplication Data by ID
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public ActionResult ManageLiquorApplication(int?Id)
        {
            LiquorApplicationModel liquorApplicationModel = new LiquorApplicationModel();

            if (Id != null && Id > 0)
            {
                using (var ctx = new LicenseApplicationContext())
                {
                    int LiquorApplicationID = Convert.ToInt32(Id);
                    var liquorApplication   = ctx.LiquorApplications.Where(a => a.LiquorApplicationID == LiquorApplicationID).FirstOrDefault();
                    liquorApplicationModel = Mapper.Map <LiquorApplicationModel>(liquorApplication);
                }
            }

            if (ProjectSession.User != null && ProjectSession.User.RoleTemplateID > 0)
            {
                liquorApplicationModel.UserRollTemplate = ProjectSession.User.RoleTemplateID.Value;
                liquorApplicationModel.UsersID          = ProjectSession.User.UsersID;
            }
            liquorApplicationModel.IsDraft = false;
            return(View(liquorApplicationModel));
        }
Ejemplo n.º 2
0
        public ActionResult ManageLiquorApplication(LiquorApplicationModel liquorApplicationModel)
        {
            if (ModelState.IsValid)
            {
                using (var ctx = new LicenseApplicationContext())
                {
                    LiquorApplication liquorApplication;
                    liquorApplication = Mapper.Map <LiquorApplication>(liquorApplicationModel);

                    int UserroleTemplate = 0;
                    if (ProjectSession.User != null && ProjectSession.UserID > 0)
                    {
                        liquorApplication.UpdatedBy = ProjectSession.User.Username;

                        #region Set PAStatus Value

                        if (ProjectSession.User.RoleTemplateID != null)
                        {
                            UserroleTemplate = ProjectSession.User.RoleTemplateID.Value;
                        }

                        if (liquorApplicationModel.IsDraft)
                        {
                            if (UserroleTemplate == (int)RollTemplate.Public || UserroleTemplate == (int)RollTemplate.DeskOfficer)
                            {
                                liquorApplication.AppStatusID = (int)PAStausenum.submittedtoclerk;
                            }
                        }
                        else
                        {
                            if (UserroleTemplate == (int)RollTemplate.Public || UserroleTemplate == (int)RollTemplate.DeskOfficer)
                            {
                                liquorApplication.AppStatusID = (int)PAStausenum.draftcreated;
                            }
                        }



                        #endregion
                    }

                    liquorApplication.DateSubmitted = DateTime.Now;

                    ctx.LiquorApplications.AddOrUpdate(liquorApplication);
                    ctx.SaveChanges();

                    int liquorApplicationID = liquorApplication.LiquorApplicationID;

                    int roleTemplate = 0;
                    if (ProjectSession.User != null && ProjectSession.User.RoleTemplateID > 0)
                    {
                        roleTemplate = ProjectSession.User.RoleTemplateID.Value;
                    }

                    if (UserroleTemplate == (int)RollTemplate.Public)
                    {
                        if (!string.IsNullOrWhiteSpace(liquorApplicationModel.UploadRequiredDocids))
                        {
                            string[] ids = liquorApplicationModel.UploadRequiredDocids.Split(',');
                            List <RequiredDocList> RequiredDoclist = new List <RequiredDocList>();

                            foreach (string id in ids)
                            {
                                string[] rId = id.Split(':');

                                RequiredDocList requiredDocList = new RequiredDocList();
                                requiredDocList.RequiredDocID = Convert.ToInt32(rId[0]);
                                requiredDocList.AttachmentID  = Convert.ToInt32(rId[1]);
                                RequiredDoclist.Add(requiredDocList);
                            }
                        }
                    }
                    else if (UserroleTemplate == (int)RollTemplate.DeskOfficer)
                    {
                        if (!string.IsNullOrWhiteSpace(liquorApplicationModel.RequiredDocIds))
                        {
                            string[]   ids             = liquorApplicationModel.RequiredDocIds.Split(',');
                            List <int> RequiredDoclist = new List <int>();

                            foreach (string id in ids)
                            {
                                int RequiredDocID = Convert.ToInt32(id);
                                RequiredDoclist.Add(RequiredDocID);
                            }
                        }
                    }
                }

                TempData["SuccessMessage"] = "Liquor License Application saved successfully.";

                return(RedirectToAction("LiquorApplication"));
            }
            else
            {
                return(View(liquorApplicationModel));
            }
        }