Example #1
0
 public void Delete(EmployeeFunc obj)
 {
     _service.Delete(obj);
 }
Example #2
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));
                }
            }
        }