public JsonResult DeleteCompany(int id)
        {
            var result = CompanyBusinessLogic.Delete(id);

            if (result)
            {
                return(Json(new { Success = true, Message = "Delete Successfully." }));
            }
            return(Json(new { Success = false, Message = "Error in transaction." }));
        }
 public ActionResult Save(tblCompanyDTO tblCompanyDTO)
 {
     if (ModelState.IsValid)
     {
         var result = CompanyBusinessLogic.Save(tblCompanyDTO);
         if (result > 0)
         {
             return(RedirectToAction("Index"));
         }
     }
     return(View(tblCompanyDTO));
 }
        public ActionResult Save(int id)
        {
            tblCompanyDTO tblCompanyDTO;

            if (id == 0)
            {
                tblCompanyDTO = new tblCompanyDTO();
            }
            else
            {
                tblCompanyDTO = CompanyBusinessLogic.Get(id);
            }
            return(View(tblCompanyDTO));
        }
Esempio n. 4
0
 private void DoWork(object state)
 {
     using (var scope = _scopeFactory.CreateScope())
     {
         var      _context = scope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
         DateTime date     = DateTime.Now;
         foreach (Company company in _context.Companies.Where(c => !c.IsEnd))
         {
             // Company comp = _context.Companies.Find(company.Id);
             if (CompanyBusinessLogic.EndCompanyIfTime(company))
             {
                 _logger.LogInformation($"Company '{company.Name}' is ended");
             }
         }
         _context.SaveChanges();
     }
 }
Esempio n. 5
0
        public async Task <ClaimsIdentity> GenerateUserIdentityAsync(UserManager <ApplicationUser> manager)
        {
            // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
            var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);

            var userName = this.UserName;
            var claims   = new List <Claim>();

            UserProfileBusinessLogic    UserBL           = new UserProfileBusinessLogic();
            CompanyBusinessLogic        CompanyBL        = new CompanyBusinessLogic();
            CompanyBranchBusinessLogic  CompanyBranchBL  = new CompanyBranchBusinessLogic();
            CompanyProfileBusinessLogic CompanyProfileBL = new CompanyProfileBusinessLogic();


            var loginUser = UserBL.FindUserProfile(userName);

            if (loginUser != null && loginUser.CompanyBranchID > 0)
            {
                var userCompany = CompanyBL.GetById(loginUser.CompanyBranchID);
                claims.Add(new Claim("Username", loginUser.FullName.ToString()));
                claims.Add(new Claim("UserId", loginUser.id.ToString()));
                claims.Add(new Claim("UserCode", loginUser.UserCode));
                claims.Add(new Claim("CompanyID", loginUser.CompanyBranchID.ToString()));
                claims.Add(new Claim("PartyId", userCompany.UCID != null ? userCompany.UCID.ToString() : ""));

                claims.Add(new Claim("TradeLicenseNumber", string.IsNullOrEmpty(userCompany.TradeLicenseNumber) ? string.Empty : userCompany.TradeLicenseNumber));

                var company_profiles = CompanyBL.GetCompanyProfiles((int?)loginUser.CompanyBranchID)
                                       .Select(a => a.CompanyProfileCode).ToList <string>();
                if (company_profiles != null)
                {
                    claims.Add(new Claim("CompanyProfiles", string.Join(",", company_profiles)));
                }
                int?mainprofileID = userCompany.MainProfileID;
                var mainProfile   = mainprofileID == null ? null : CompanyProfileBL.GetById(mainprofileID).CompanyProfileCode;
                if (mainProfile != null)
                {
                    claims.Add(new Claim("CompanyMainProfile", mainProfile));
                }
                if (mainProfile == "TOP")
                {
                    var terminal = CompanyBranchBL.GetCompanyBranchTerminal(loginUser.CompanyBranchID);
                    if (terminal != null)
                    {
                        claims.Add(new Claim("TerminalCode", terminal.TerminalCode));
                        claims.Add(new Claim("TerminalID", terminal.TerminalID.ToString()));
                    }
                }

                //if ((mainProfile == "HSE" || mainProfile == "HBM" || mainProfile == "MRS"
                //                || company_profiles.Contains("HSE") || company_profiles.Contains("HBM") || company_profiles.Contains("MRS")) && loginUser.Role != Enums.Roles.SuperAdmin.GetDescription())
                //{
                //    if (new CommonRepository().CheckMarsaStatus())
                //        return null;
                //}
            }

            else
            {
                return(null);
            }
            userIdentity.AddClaims(claims);
            // Add custom user claims here
            return(userIdentity);
        }
        public ActionResult _AjaxGetCompany()
        {
            var CompanyList = CompanyBusinessLogic.GetAll();

            return(View(new GridModel(CompanyList)));
        }