Ejemplo n.º 1
0
        public ActionResult SaveFunction(string EmpId, List <int> FuncId, string BranchCode)
        {
            if (EmpId != null)
            {
                List <FuncSL> Funcs = new List <FuncSL>();

                foreach (var id in FuncId)
                {
                    FuncSL Func = _funcSLService.All().Where(m => m.FuncId == id).FirstOrDefault();
                    Funcs.Add(Func);
                }

                foreach (var item in Funcs)
                {
                    var selectedFunc = _employeeFuncService.All().ToList().FirstOrDefault(x => x.FuncSl == item.FuncSl && x.EmpId == EmpId);
                    if (selectedFunc != null)
                    {
                        _employeeFuncService.Update(selectedFunc);
                        _employeeFuncService.Save();
                    }
                    else
                    {
                        EmployeeFunc emp = new EmployeeFunc();
                        emp.Id       = GenerateEmpId();
                        emp.FuncSl   = item.FuncSl;
                        emp.EmpId    = EmpId;
                        emp.Form     = item.Form;
                        emp.Function = item.Function;
                        Employee empo = new Employee();
                        emp.BranchCode = BranchCode;

                        //  var employee = _employeeService.All().ToList().FirstOrDefault(x => x.Id == Convert.ToInt16(EmpId));
                        //var userbranch = _userbranchService.All().ToList().FirstOrDefault(x => x.Userid == EmpId);

                        //emp.BranchCode = userbranch.BranchCode;

                        _employeeFuncService.Add(emp);
                        _employeeFuncService.Save();
                    }
                }
                return(Json("1", JsonRequestBehavior.AllowGet));
            }
            return(Json("0", JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
 public void Setvalues(EmployeeFunc entity, EmployeeFunc existingEntity)
 {
     _service.Setvalues(entity, existingEntity);
 }
Ejemplo n.º 3
0
 public void Delete(EmployeeFunc obj)
 {
     _service.Delete(obj);
 }
Ejemplo n.º 4
0
 public void Update(EmployeeFunc obj)
 {
     _service.Update(obj);
 }
Ejemplo n.º 5
0
 public void Add(EmployeeFunc obj)
 {
     _service.Add(obj);
 }
Ejemplo n.º 6
0
        public ActionResult SaveSignatoryManagement(string UserName, List <FuncSL> Check)
        {
            using (var transaction = new TransactionScope())
            {
                try
                {
                    //RBACUser rUser = new RBACUser(Session["UserName"].ToString());
                    //if (!rUser.HasPermission("Signatory_Insert"))
                    //{
                    //    return Json("X", JsonRequestBehavior.AllowGet);
                    //}
                    var UserId      = _employeeService.All().Where(x => x.UserName == UserName).Select(x => x.Id).LastOrDefault();
                    var IsExistuser = _employeefuncService.All().Where(x => x.EmpId == UserId).ToList();
                    foreach (var data in IsExistuser)
                    {
                        _employeefuncService.Delete(data);
                        _employeefuncService.Save();
                    }

                    var IfExit = _employeeService.All().Where(x => x.UserName == UserName).LastOrDefault();
                    if (IfExit == null)
                    {
                        Employee EmployeeAdd = new Employee();
                        EmployeeAdd.FullName = UserName;
                        EmployeeAdd.UserName = UserName;
                        //EmployeeAdd.UserRank = 1;
                        EmployeeAdd.BranchCode = "001";
                        EmployeeAdd.IsActive   = true;
                        _employeeService.Add(EmployeeAdd);
                        _employeeService.Save();
                    }


                    if (Check != null)
                    {
                        foreach (var data in Check)
                        {
                            //  var IfExist = _acbrServic.All().Where(x => x.Accode == data.Accode && x.BranchCode == data.BranchCode).FirstOrDefault();
                            if (Check.Count != 0)
                            {
                                List <EmployeeFunc> emfuncList = new List <EmployeeFunc>();
                                EmployeeFunc        emfunc     = new EmployeeFunc();
                                emfunc.BranchCode = "001";
                                emfunc.FormName   = data.FormName;
                                emfunc.FuncName   = data.FuncName;
                                emfunc.FuncSl     = Convert.ToInt32(data.FuncSl);
                                emfunc.EmpId      = _employeeService.All().ToList().Where(x => x.UserName == UserName).Select(x => x.Id).FirstOrDefault();
                                emfuncList.Add(emfunc);
                                _employeefuncService.Add(emfunc);
                                _employeefuncService.Save();
                            }
                        }
                    }
                    transaction.Complete();

                    return(Json("1", JsonRequestBehavior.AllowGet));
                }
                catch (Exception)
                {
                    transaction.Dispose();
                    return(Json("0", JsonRequestBehavior.AllowGet));
                }
            }
        }