public Result SaveCompanyBranch(SET_CompanyBranch companyBranch)
        {
            _result = new Result();
            _companyBranchFactory = new CompanyBranchFactory();
            try
            {
                Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
                int userGroupId = Convert.ToInt32(dictionary[6].Id == "" ? 0 : Convert.ToInt32(dictionary[6].Id));
                if (userGroupId != 0)
                {
                    if (companyBranch.BranchID > 0)
                    {
                        _companyBranchFactory.Edit(companyBranch);
                        _result = _companyBranchFactory.Save();
                    }
                    else
                    {
                        int branchID    = 1;
                        var prvBranchID = _companyBranchFactory.GetLastRecord().OrderByDescending(x => x.BranchID).FirstOrDefault();
                        if (prvBranchID != null)
                        {
                            branchID = prvBranchID.BranchID + 1;
                        }

                        companyBranch.BranchID = branchID;
                        _companyBranchFactory.Add(companyBranch);
                        _result = _companyBranchFactory.Save();
                    }
                }
                else
                {
                    _result.isSucess = false;
                    _result.message  = "Logout";
                }
            }
            catch (Exception e)
            {
                _result.isSucess = false;
                _result.message  = e.Message;
            }

            return(_result);
        }
Beispiel #2
0
        public JsonResult SaveCompanyBranch(SET_CompanyBranch companyBranch)
        {
            result = new Result();
            companyBranchFactory = new CompanyBranchFactorys();
            Dictionary <int, CheckSessionData> dictionary = CheckSessionData.GetSessionValues();
            int empId = Convert.ToInt32(dictionary[1].Id);

            if (companyBranch.BranchID > 0)
            {
                companyBranch.UpdatedBy   = empId;
                companyBranch.UpdatedDate = DateTime.Now;
            }
            else
            {
                companyBranch.CreatedBy   = empId;
                companyBranch.CreatedDate = DateTime.Now;
            }
            result = companyBranchFactory.SaveCompanyBranch(companyBranch);
            return(Json(result));
        }