public async Task <IActionResult> EditLeader(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var user = await _context.Users.FirstOrDefaultAsync(u => u.Id == id);

            if (user == null)
            {
                return(NotFound());
            }

            var isLeader = await _userManager.IsInRoleAsync(user, Roles.Leader);

            if (!isLeader)
            {
                return(NotFound());
            }

            var userSaveModel = new UserSaveModel {
                Firstname   = user.FirstName,
                Lastname    = user.LastName,
                Email       = user.Email,
                PhoneNumber = user.PhoneNumber
            };

            return(View(userSaveModel));
        }
        public async Task <IActionResult> EditLeader(string id, [FromForm] UserSaveModel userSaveModel)
        {
            if (ModelState.IsValid)
            {
                return(View(userSaveModel));
            }

            var user = await _context.Users.FirstOrDefaultAsync(u => u.Id == id);

            if (user == null)
            {
                return(NotFound());
            }

            var isLeader = await _userManager.IsInRoleAsync(user, Roles.Leader);

            if (!isLeader)
            {
                return(NotFound());
            }

            user.FirstName   = userSaveModel.Firstname;
            user.LastName    = userSaveModel.Lastname;
            user.PhoneNumber = userSaveModel.PhoneNumber;

            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Leaders)));
        }
        public async Task <IActionResult> CreateStaff(UserSaveModel userSaveModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(userSaveModel));
            }

            var duplicate = await _userManager.FindByNameAsync(userSaveModel.Email);

            if (duplicate != null)
            {
                //adding error message to ModelState
                ModelState.AddModelError("Email", "Email đã được người khác sử dụng.");
                return(View(userSaveModel));
            }

            var user = new User()
            {
                FirstName   = userSaveModel.Firstname,
                LastName    = userSaveModel.Lastname,
                UserName    = userSaveModel.Email,
                Email       = userSaveModel.Email,
                PhoneNumber = userSaveModel.PhoneNumber,
            };

            var result = await _userManager.CreateAsync(user, userSaveModel.Password);

            if (result.Succeeded)
            {
                await _userManager.AddToRoleAsync(user, Roles.Staff);
            }

            return(RedirectToAction(nameof(Staffs)));
        }
Пример #4
0
        public static Hashtable ChangePasswordDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();



                if (Type == "Update")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"]);
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"]);
                    ht_param.Add("@Contact_ID", ht["Contact_ID"].ToString());
                    ht_param.Add("@Login_user_ID", HttpContext.Current.Session["Login_user_ID"]);
                    ht_param.Add("@Old_Password", ht["Old_Password"].ToString());
                    ht_param.Add("@New_password", ht["New_password"].ToString());
                    ht_param.Add("@MODE", ht["MODE"].ToString());
                    ds = db.SysFetchDataInDataSet("[CHANGE_RESET_PASSWORD]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Update"] = serializer.Serialize(_UserSaveModel);
                }



                _ErrorModel.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "sucess";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _ErrorModel.Clear();
                ReturnData.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
Пример #5
0
        public virtual Task <HttpResponseMessage> Save(UserSaveModel registerModel)
        {
            var resultMsg = new RegisterResultRequest();

            resultMsg.Detail  = "";
            resultMsg.Params  = "";
            resultMsg.Status  = 400;
            resultMsg.Params  = "";
            resultMsg.TraceId = "";
            resultMsg.Type    = "";
            if (registerModel.Login == SuccessUsername)
            {
                return(Task.Run(() => new HttpResponseMessage()
                {
                    StatusCode = HttpStatusCode.OK,
                    Content = new StringContent("")
                }));
            }

            if (registerModel.Login == EmailUsername)
            {
                resultMsg.Type = ErrorConst.EmailAlreadyUsedType;
            }

            if (registerModel.Login == LoginUsername)
            {
                resultMsg.Type = ErrorConst.LoginAlreadyUsedType;
            }

            return(Task.Run(() => new HttpResponseMessage()
            {
                StatusCode = HttpStatusCode.BadRequest,
                Content = new StringContent(JsonSerializer.Serialize(resultMsg), Encoding.UTF8, "application/json")
            }));
        }
Пример #6
0
        public async Task <string> Save(UserSaveModel registerModel)
        {
            var resp = await _httpClient.PostAsJsonAsync(RegisterUrl, registerModel);

            if (resp.IsSuccessStatusCode)
            {
                return(null);
            }
            return(await ProcessError(resp));
        }
Пример #7
0
        /// <summary>
        /// 將記憶體內的UserModel轉為儲存用的UserSaveModel
        /// </summary>
        /// <param name="userModel"></param>
        /// <returns></returns>
        public static UserSaveModel ConvertToSaveModel(UserModel userModel)
        {
            UserSaveModel userSaveModel = new UserSaveModel();
            string        wwww          = $"{userModel.Account}|{userModel.Password}|{userModel.Name}|{userModel.isAdmin}";

            userSaveModel.Id              = userModel.Id;
            userSaveModel.SaltKey         = userModel.SaltKey;
            userSaveModel.Account         = userModel.Account;
            userSaveModel.UserModelString = MD5.MD5Encrypt(wwww, userSaveModel.SaltKey);

            return(userSaveModel);
        }
Пример #8
0
        public async Task <bool> SaveUser(UserSaveModel model, int userId)
        {
            bool result = false;

            try
            {
                using (SocialCRMEntities db = new SocialCRMEntities())
                {
                    var form = new AspNetUser();
                    if (model.Id > 0)
                    {
                        form = db.AspNetUsers.Find(model.Id);
                    }
                    else
                    {
                    }


                    if (model.Id > 0)
                    {
                        //form.Categories.Clear();
                        //foreach (var item in categories)
                        //{
                        //    form.Categories.Add(db.Categories.Find(item));
                        //}
                        //db.MediaNews.Attach(form);
                        //db.Entry(form).State = EntityState.Modified;
                    }
                    else
                    {
                        //foreach (var item in categories)
                        //{
                        //    form.Categories.Add(db.Categories.Find(item));
                        //}
                        //db.MediaNews.Add(form);
                    }
                    db.SaveChanges();
                    result = true;
                }
            }
            catch (Exception ex)
            {
                result = false;
            }
            return(result);
        }
Пример #9
0
        public async Task <IActionResult> UserSave(UserSaveModel model)
        {
            if (ModelState.IsValid)
            {
                User user = await _userManager.FindByIdAsync(model.Id.ToString());

                if (user != null)
                {
                    Mapper.Map(model, user);
                    //user.Email = model.Email;
                    //user.UserName = model.Email;
                    //user.Year = model.Year;

                    // получем список ролей пользователя
                    var userRoles = await _userManager.GetRolesAsync(user);

                    // получаем все роли
                    var allRoles = _roleManager.Roles.ToList();

                    var addedRoles   = model.Roles.Except(userRoles);
                    var removedRoles = userRoles.Except(model.Roles);

                    await _userManager.AddToRolesAsync(user, addedRoles);

                    await _userManager.RemoveFromRolesAsync(user, removedRoles);

                    var result = await _userManager.UpdateAsync(user);

                    if (result.Succeeded)
                    {
                        return(RedirectToAction("Users"));
                    }
                    else
                    {
                        foreach (var error in result.Errors)
                        {
                            ModelState.AddModelError(string.Empty, error.Description);
                        }
                    }
                }
            }

            return(Content("Такого юзера не существует"));
        }
        public async Task <IActionResult> Save([FromBody] UserSaveModel user)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    List <string> errors = new List <string>();

                    foreach (var modelState in ModelState.Values)
                    {
                        errors.Add(string.Join(", ", modelState.Errors.Select(k => k.ErrorMessage)));
                    }

                    if (errors.Count > 0)
                    {
                        throw new ClientException(string.Join(", ", errors));
                    }
                }

                string ADMIN_ID = config.GetValue <string>("Tokens:SysUsers:Admin");

                if (user.id == ADMIN_ID && user.userName != "admin")
                {
                    throw new Exception("System admin username cannot be changed!");
                }

                _userMethods.Save(user);

                await observerHub.Clients.User(user.id).SendAsync("SessionEnd", "your profile information has been modified, you are required to login again");

                return(Ok(user));
            }
            catch (ClientException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, new { message = ex.Message }));
            }
        }
Пример #11
0
        /// <summary>
        /// 將文檔取回的SaveModel轉回UserModel
        /// </summary>
        /// <param name="userSaveModel"></param>
        /// <returns></returns>
        public static UserModel ConvertToUserModel(UserSaveModel userSaveModel)
        {
            try
            {
                UserModel userModel = new UserModel();
                string    aa        = MD5.MD5Decrypt(userSaveModel.UserModelString, userSaveModel.SaltKey);
                string[]  sss       = aa.Split('|');

                userModel.Id      = userSaveModel.Id;
                userModel.SaltKey = userSaveModel.SaltKey;

                userModel.Account  = sss[0];
                userModel.Password = sss[1];
                userModel.Name     = sss[2];
                userModel.isAdmin  = Convert.ToBoolean(sss[3]);

                return(userModel);
            }
            catch (Exception ex)
            {
                //log here
                return(null);
            }
        }
Пример #12
0
        public static Hashtable ContactDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    AgentListModel_list.Clear();
                    ht_param.Clear();
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[GetAgentPersonalDetails]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        AgentListModel_list = ds.Tables[0].AsEnumerable()
                                              .Select(row => new AgentListModel
                        {
                            ID            = row["ID"].ToString(),
                            Name          = row["Name"].ToString(),
                            MobileNo      = row["MobileNo"].ToString(),
                            Email         = row["Email"].ToString(),
                            Gender        = row["Gender"].ToString(),
                            ImageURL      = row["ImageURL"].ToString(),
                            country_id    = row["country_id"].ToString(),
                            state_id      = row["state_id"].ToString(),
                            district_id   = row["district_id"].ToString(),
                            Address       = row["Address"].ToString(),
                            pincode       = row["pincode"].ToString(),
                            IsAgentActive = row["IsAgentActive"].ToString()
                        }).ToList();
                    }
                    ReturnData["AgentData"] = serializer.Serialize(AgentListModel_list);
                }


                if (Type == "StatusUpdate")
                {
                    _UserSaveModel.Clear();
                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ds = db.SysFetchDataInDataSet("[UpdateAgentActiveStatus]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["CompanyData"] = serializer.Serialize(_UserSaveModel);
                    //ReturnData["ContactData"] = serializer.Serialize("deleted successfully.");
                }


                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "Success";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);

                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
Пример #13
0
        public static Hashtable ContactDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    words = null;
                    words = Req.Split('@');
                    for (int m = 0; words.Count() > m; m++)
                    {
                        Data = words[m].ToString();

                        if (Data == "Country")
                        {
                            _CountryModel.Clear();
                            ht_param.Clear();
                            ds = db.SysFetchDataInDataSet("[GetCountryList]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                foreach (DataRow item in ds.Tables[0].Rows)
                                {
                                    CountryModel CountryModel_Detail = new CountryModel();
                                    CountryModel_Detail.Name       = item["NAME"].ToString();
                                    CountryModel_Detail.COUNTRY_ID = Convert.ToInt32(item["COUNTRY_ID"].ToString());
                                    _CountryModel.Add(CountryModel_Detail);
                                }
                            }
                            ReturnData["Country"] = serializer.Serialize(_CountryModel);

                            _Role_ddl_Model.Clear();
                            ht_param.Clear();
                            ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                            ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[GetRoleList]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                foreach (DataRow item in ds.Tables[0].Rows)
                                {
                                    Role_ddl_Model _Role_ddl_ModelDetail = new Role_ddl_Model();
                                    _Role_ddl_ModelDetail.Name = item["NAME"].ToString();
                                    _Role_ddl_ModelDetail.ID   = Convert.ToInt32(item["ID"].ToString());
                                    _Role_ddl_Model.Add(_Role_ddl_ModelDetail);
                                }
                            }
                            ReturnData["Role"] = serializer.Serialize(_Role_ddl_Model);



                            GetStateforDefaultCountry(_CountryModel[0].COUNTRY_ID.ToString());
                        }
                        if (Data == "Edit")
                        {
                            _CountryModel.Clear();
                            _Role_ddl_Model.Clear();
                            ht_param.Clear();
                            ht_param.Add("@ID", ht["ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[GetSelectedContactDetails]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                _Contactlist = ds.Tables[0].AsEnumerable()
                                               .Select(row => new ContactModel
                                {
                                    ID       = row["ID"].ToString(),
                                    Name     = row["Name"].ToString(),
                                    RName    = row["RoleId"].ToString(),
                                    MobileNo = row["MobileNo"].ToString(),
                                    PhoneNo  = row["PhoneNo"].ToString(),
                                    Email    = row["Email"].ToString(),
                                    Password = row["Password"].ToString(),
                                    Country  = row["Country"].ToString(),
                                    City     = row["City"].ToString(),
                                    State    = row["State"].ToString(),
                                    Address  = row["Address"].ToString(),
                                    LogoPath = row["LogoPath"].ToString(),
                                    IsActive = row["IsActive"].ToString()
                                }).ToList();
                            }
                            ReturnData["ContactData"] = serializer.Serialize(_Contactlist);
                            GetStateforDefaultCountry(_Contactlist[0].Country);
                        }
                    }
                }


                if (Type == "State")
                {
                    _CountryModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@COUNTRY_ID", ht["COUNTRY_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[GetStateList]", ht_param);

                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            CountryModel CountryModel_Detail = new CountryModel();
                            CountryModel_Detail.Name       = item["NAME"].ToString();
                            CountryModel_Detail.COUNTRY_ID = Convert.ToInt32(item["LOCATION_ID"].ToString());
                            _CountryModel.Add(CountryModel_Detail);
                        }
                    }
                    ReturnData["State"] = serializer.Serialize(_CountryModel);
                }


                if (Type == "Save")
                {
                    _UserSaveModel.Clear();
                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("Name", ht["Name"].ToString());
                    if (ht["RoleId"].ToString() == "")
                    {
                        ht_param.Add("@RoleId", DBNull.Value);
                    }
                    else
                    {
                        ht_param.Add("@RoleId", ht["RoleId"].ToString());
                    }
                    ht_param.Add("@MobileNo", ht["MobileNo"].ToString());
                    ht_param.Add("@PhoneNo", ht["PhoneNo"].ToString());
                    ht_param.Add("@Email", ht["Email"].ToString());
                    ht_param.Add("@Password", ht["Password"].ToString());
                    if (ht["Country"].ToString() == "")
                    {
                        ht_param.Add("@Country", DBNull.Value);
                    }
                    else
                    {
                        ht_param.Add("@Country", ht["Country"].ToString());
                    }

                    if (ht["State"].ToString() == "")
                    {
                        ht_param.Add("@State", DBNull.Value);
                    }
                    else
                    {
                        ht_param.Add("@State", ht["State"].ToString());
                    }
                    ht_param.Add("@City", ht["City"].ToString());
                    ht_param.Add("@Type", ht["Type"].ToString());
                    ht_param.Add("@Address", ht["Address"].ToString());
                    ht_param.Add("@LogoPath", ht["Logo"].ToString());
                    ht_param.Add("@IsStatus", ht["IsStatus"].ToString());
                    ht_param.Add("@MODE", ht["MODE"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@Login_user_ID", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[INSERT_Contact_DETAILS]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Save"] = serializer.Serialize(_UserSaveModel);
                    //ReturnData["Save"] = serializer.Serialize("saved successfully.");
                }


                if (Type == "Update")
                {
                    _UserSaveModel.Clear();
                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("@Name", ht["Name"].ToString());
                    if (ht["RoleId"].ToString() == "")
                    {
                        ht_param.Add("@RoleId", DBNull.Value);
                    }
                    else
                    {
                        ht_param.Add("@RoleId", ht["RoleId"].ToString());
                    }
                    ht_param.Add("@MobileNo", ht["MobileNo"].ToString());
                    ht_param.Add("@PhoneNo", ht["PhoneNo"].ToString());
                    ht_param.Add("@Email", ht["Email"].ToString());
                    ht_param.Add("@Password", ht["Password"].ToString());
                    if (ht["Country"].ToString() == "")
                    {
                        ht_param.Add("@Country", DBNull.Value);
                    }
                    else
                    {
                        ht_param.Add("@Country", ht["Country"].ToString());
                    }

                    if (ht["State"].ToString() == "")
                    {
                        ht_param.Add("@State", DBNull.Value);
                    }
                    else
                    {
                        ht_param.Add("@State", ht["State"].ToString());
                    }
                    ht_param.Add("@City", ht["City"].ToString());
                    ht_param.Add("@Type", ht["Type"].ToString());
                    ht_param.Add("@Address", ht["Address"].ToString());
                    ht_param.Add("@LogoPath", ht["Logo"].ToString());
                    ht_param.Add("@IsStatus", ht["IsStatus"].ToString());
                    ht_param.Add("@MODE", ht["MODE"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@Login_user_ID", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[INSERT_Contact_DETAILS]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Update"] = serializer.Serialize(_UserSaveModel);
                    //ReturnData["Update"] = serializer.Serialize("updated successfully.");
                }


                _ErrorModel.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "sucess";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _ErrorModel.Clear();
                ReturnData.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
Пример #14
0
        private User CreateUpdateUser(UserSaveModel userSaveModel, Customer customer, List <Department> departments)
        {
            User user;

            if (string.IsNullOrWhiteSpace(userSaveModel.Id))
            {
                user       = new User();
                user.Name  = userSaveModel.Name;
                user.Email = userSaveModel.Email;

                user.PhoneNumber = userSaveModel.Phone;
                user.UserName    = userSaveModel.UserName;
                user.UserInfo    = new UserInfo
                {
                    User       = user,
                    Customer   = customer,
                    Department = departments.FirstOrDefault(d => d.Name == userSaveModel.DepartmentName),
                };
                var res = _unitOfWork.UserManager.CreateAsync(user, userSaveModel.Password).GetAwaiter().GetResult();
                if (res.Succeeded)
                {
                    var addToRoleRes = _unitOfWork.UserManager.AddToRoleAsync(user, Roles.UserRole).GetAwaiter().GetResult();
                    if (!res.Succeeded)
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                user = _unitOfWork.UserRepository.Get(e => e.UserInfo).FirstOrDefault(u => u.Id == userSaveModel.Id);
                if (user == null)
                {
                    return(null);
                }
                else
                {
                    user.Name        = userSaveModel.Name;
                    user.PhoneNumber = userSaveModel.Phone;
                    user.UserName    = userSaveModel.UserName;
                    user.Email       = userSaveModel.Email;
                    if (user.UserInfo == null)
                    {
                        user.UserInfo = new UserInfo {
                            User = user
                        };
                        user.UserInfo.Department = departments.FirstOrDefault(d => d.Name == userSaveModel.DepartmentName);
                    }

                    var res = _unitOfWork.UserManager.UpdateAsync(user).GetAwaiter().GetResult();
                    if (!res.Succeeded)
                    {
                        return(null);
                    }
                }
            }



            return(user);
        }
Пример #15
0
        public static Hashtable TaxDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    words = null;
                    words = Req.Split('@');
                    for (int m = 0; words.Count() > m; m++)
                    {
                        Data = words[m].ToString();

                        if (Data == "CATEGORY")
                        {
                            _ItemCategoryModel.Clear();
                            ht_param.Clear();
                            ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                            ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                            ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[GET_ITEM_CATEGORY]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                foreach (DataRow item in ds.Tables[0].Rows)
                                {
                                    ItemCategoryModel ItemCategoryModel_Detail = new ItemCategoryModel();
                                    ItemCategoryModel_Detail.NAME = item["NAME"].ToString();
                                    ItemCategoryModel_Detail.ID   = item["ID"].ToString();
                                    _ItemCategoryModel.Add(ItemCategoryModel_Detail);
                                }
                            }
                            ReturnData["CATEGORY"] = serializer.Serialize(_ItemCategoryModel);
                        }
                        if (Data == "GST")
                        {
                            _gstModel.Clear();
                            ht_param.Clear();
                            ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                            ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                            ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[GET_GST]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                foreach (DataRow item in ds.Tables[0].Rows)
                                {
                                    gstModel gstModel_Detail = new gstModel();
                                    gstModel_Detail.ID   = item["ID"].ToString();
                                    gstModel_Detail.IGST = item["IGST_PERCENTAGE"].ToString();
                                    _gstModel.Add(gstModel_Detail);
                                }
                            }
                            ReturnData["GST"] = serializer.Serialize(_gstModel);
                        }


                        if (Data == "Edit")
                        {
                            ht_param.Clear();
                            ht_param.Add("@ID", ht["ID"].ToString());
                            ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                            ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                            ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[GET_ITEM_DETAILS]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                _ItemDetailsModel = ds.Tables[0].AsEnumerable()
                                                    .Select(row => new ItemDetailsModel
                                {
                                    ID                  = row["ID"].ToString(),
                                    CATEGORY_ID         = row["CATEGORY_ID"].ToString(),
                                    NAME                = row["NAME"].ToString(),
                                    PBO_PRICE           = row["PBO_PRICE"].ToString(),
                                    PRODUCT_SVP         = row["PRODUCT_SVP"].ToString(),
                                    DISCOUNT_PERCENTAGE = row["DISCOUNT_PERCENTAGE"].ToString(),
                                    DISCOUNT_AMOUNT     = row["DISCOUNT_AMOUNT"].ToString(),
                                    CODE                = row["CODE"].ToString(),
                                    GST_ID              = row["GST_ID"].ToString(),
                                    MRP                 = row["MRP"].ToString(),
                                    SALE_PRICE          = row["SALE_PRICE"].ToString(),
                                    ImageURL            = row["ImageURL"].ToString(),
                                    IsActive            = row["IsActive"].ToString(),
                                    CATEGORY_NAME       = row["CATEGORY_NAME"].ToString(),
                                    IGST_PERCENTAGE     = row["IGST_PERCENTAGE"].ToString(),
                                    CGST_PERCENTAGE     = row["CGST_PERCENTAGE"].ToString(),
                                    SGST_PERCENTAGE     = row["SGST_PERCENTAGE"].ToString()
                                }).ToList();
                            }

                            ReturnData["TaxData"] = serializer.Serialize(_ItemDetailsModel);
                        }
                    }
                }

                if (Type == "Save")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@CATEGORY_ID", ht["CATEGORY_ID"].ToString());
                    ht_param.Add("@NAME", ht["NAME"].ToString());
                    ht_param.Add("@PBO_PRICE", ht["PBO_PRICE"].ToString());
                    ht_param.Add("@PRODUCT_SVP", ht["PRODUCT_SVP"].ToString());
                    ht_param.Add("@DISCOUNT_PERCENTAGE", ht["DISCOUNT_PERCENTAGE"].ToString());
                    ht_param.Add("@DISCOUNT_AMOUNT", ht["DISCOUNT_AMOUNT"].ToString());
                    ht_param.Add("@CODE", ht["CODE"].ToString());
                    ht_param.Add("@GST_ID", ht["GST_ID"].ToString());
                    ht_param.Add("@MRP", ht["MRP"].ToString());
                    ht_param.Add("@SALE_PRICE", ht["SALE_PRICE"].ToString());
                    ht_param.Add("@IsActive", ht["IsActive"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_ITEM_DETAILS]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Save"] = serializer.Serialize(_UserSaveModel);
                }


                if (Type == "Update")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("@CATEGORY_ID", ht["CATEGORY_ID"].ToString());
                    ht_param.Add("@NAME", ht["NAME"].ToString());
                    ht_param.Add("@PBO_PRICE", ht["PBO_PRICE"].ToString());
                    ht_param.Add("@PRODUCT_SVP", ht["PRODUCT_SVP"].ToString());
                    ht_param.Add("@DISCOUNT_PERCENTAGE", ht["DISCOUNT_PERCENTAGE"].ToString());
                    ht_param.Add("@DISCOUNT_AMOUNT", ht["DISCOUNT_AMOUNT"].ToString());
                    ht_param.Add("@CODE", ht["CODE"].ToString());
                    ht_param.Add("@GST_ID", ht["GST_ID"].ToString());
                    ht_param.Add("@MRP", ht["MRP"].ToString());
                    ht_param.Add("@SALE_PRICE", ht["SALE_PRICE"].ToString());
                    ht_param.Add("@IsActive", ht["IsActive"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_ITEM_DETAILS]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Update"] = serializer.Serialize(_UserSaveModel);
                }



                _ErrorModel.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "sucess";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _ErrorModel.Clear();
                ReturnData.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
Пример #16
0
        public async Task Execute(UserSaveModel model)
        {
            await _userCommand.Execute(model);

            //TODO: publish message for new role
        }
        public static Hashtable AddressDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    _Addresslist.Clear();
                    ht_param.Clear();
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[GetADDRESSList]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        _Addresslist = ds.Tables[0].AsEnumerable()
                                       .Select(row => new AddressModel
                        {
                            ID                   = row["ID"].ToString(),
                            Company_Name         = row["Company_Name"].ToString(),
                            Customer_Type        = row["Customer_Type"].ToString(),
                            Street               = row["Street"].ToString(),
                            Apt_Suite_Other      = row["Apt_Suite_Other"].ToString(),
                            City                 = row["City"].ToString(),
                            Country              = row["Country"].ToString(),
                            State                = row["State"].ToString(),
                            Zip_Code             = row["Zip_Code"].ToString(),
                            CellNo               = row["CellNo"].ToString(),
                            PhoneNo              = row["PhoneNo"].ToString(),
                            Fax                  = row["Fax"].ToString(),
                            Email                = row["Email"].ToString(),
                            WebsiteUrl           = row["WebsiteUrl"].ToString(),
                            Contact              = row["Contact"].ToString(),
                            Notes                = row["Notes"].ToString(),
                            Motor_Carrier_Number = row["Motor_Carrier_Number"].ToString(),
                            Tax_ID               = row["Tax_ID"].ToString(),
                            IsActive             = row["IsActive"].ToString()
                        }).ToList();
                    }
                    ReturnData["AddressData"] = serializer.Serialize(_Addresslist);
                }

                if (Type == "Delete")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("@MODE", "DELETE");
                    ht_param.Add("@Login_user_ID", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[INSERT_ADDRESS_DETAILS]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["AddressData"] = serializer.Serialize(_UserSaveModel);
                    //ReturnData["CompanyData"] = serializer.Serialize("deleted successfully.");
                }


                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "Success";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);

                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
Пример #18
0
 public async Task <HttpResponseMessage> Save(UserSaveModel registerModel)
 {
     return(await _httpClient.PostAsJsonAsync(RegisterUrl, registerModel));
 }
        public static Hashtable RoleDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    ht_param.Clear();
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());

                    ds = db.SysFetchDataInDataSet("[GetRoleList]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        RoleModel_list = ds.Tables[0].AsEnumerable()
                                         .Select(row => new RoleModel
                        {
                            ID          = row["ID"].ToString(),
                            Name        = row["Name"].ToString(),
                            Short_Name  = row["Short_Name"].ToString(),
                            Description = row["Description"].ToString(),
                            IsActive    = row["IsActive"].ToString()
                        }).ToList();
                    }
                    ReturnData["RoleData"] = serializer.Serialize(RoleModel_list);
                }


                if (Type == "Delete")
                {
                    ht_param.Clear();
                    ht_param.Add("@ID", ht["Role_ID"]);
                    ht_param.Add("@MODE", "DELETE");
                    db.SysAddUpdateDelete("[INSERT_Role_DETAILS]", ref ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["RoleData"] = serializer.Serialize(_UserSaveModel);
                    //ReturnData["RoleData"] = serializer.Serialize("deleted successfully.");
                }


                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "Success";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);

                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
        public static Hashtable TaxDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    words = null;
                    words = Req.Split('@');
                    for (int m = 0; words.Count() > m; m++)
                    {
                        Data = words[m].ToString();

                        if (Data == "PaySchedule")
                        {
                            _ItemCategoryModel.Clear();
                            ht_param.Clear();
                            ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                            ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                            ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[get_PaySchedule]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                foreach (DataRow item in ds.Tables[0].Rows)
                                {
                                    ItemCategoryModel ItemCategoryModel_Detail = new ItemCategoryModel();
                                    ItemCategoryModel_Detail.NAME = item["PaySchedule"].ToString();
                                    ItemCategoryModel_Detail.ID   = item["id"].ToString();
                                    _ItemCategoryModel.Add(ItemCategoryModel_Detail);
                                }
                            }
                            ReturnData["PaySchedule"] = serializer.Serialize(_ItemCategoryModel);
                        }
                        if (Data == "TicketQueryMaster")
                        {
                            _ItemCategoryModel.Clear();
                            ht_param.Clear();
                            ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                            ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                            ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[get_TicketQueryMaster]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                foreach (DataRow item in ds.Tables[0].Rows)
                                {
                                    ItemCategoryModel ItemCategoryModel_Detail = new ItemCategoryModel();
                                    ItemCategoryModel_Detail.NAME = item["name"].ToString();
                                    ItemCategoryModel_Detail.ID   = item["id"].ToString();
                                    _ItemCategoryModel.Add(ItemCategoryModel_Detail);
                                }
                            }
                            ReturnData["TicketQueryMaster"] = serializer.Serialize(_ItemCategoryModel);
                        }
                        if (Data == "TicketQueryReasonMaster")
                        {
                            _TicketQueryReasonMasterModel.Clear();
                            ht_param.Clear();
                            ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                            ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                            ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                            ht_param.Add("@TicketQueryMasterId", ht["TicketQueryMasterId"].ToString());
                            ds = db.SysFetchDataInDataSet("[get_TicketQueryReasonMaster]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                foreach (DataRow item in ds.Tables[0].Rows)
                                {
                                    TicketQueryReasonMasterModel TicketQueryReasonMasterModel_Detail = new TicketQueryReasonMasterModel();
                                    TicketQueryReasonMasterModel_Detail.id              = item["id"].ToString();
                                    TicketQueryReasonMasterModel_Detail.name            = item["name"].ToString();
                                    TicketQueryReasonMasterModel_Detail.PayScheduleNo   = item["PayScheduleNo"].ToString();
                                    TicketQueryReasonMasterModel_Detail.CreditedAmount  = item["CreditedAmount"].ToString();
                                    TicketQueryReasonMasterModel_Detail.EstimatedAmount = item["EstimatedAmount"].ToString();
                                    TicketQueryReasonMasterModel_Detail.Comments        = item["Comments"].ToString();
                                    TicketQueryReasonMasterModel_Detail.orderid         = item["orderid"].ToString();
                                    TicketQueryReasonMasterModel_Detail.Attatchments    = item["Attatchments"].ToString();
                                    TicketQueryReasonMasterModel_Detail.subject         = item["subject"].ToString();
                                    _TicketQueryReasonMasterModel.Add(TicketQueryReasonMasterModel_Detail);
                                }
                            }
                            ReturnData["TicketQueryReasonMaster"] = serializer.Serialize(_TicketQueryReasonMasterModel);
                        }
                    }
                }

                if (Type == "Save")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@TicketQueryMasterId", ht["TicketQueryMasterId"].ToString());
                    ht_param.Add("@TicketQueryReasonMasterId", ht["TicketQueryReasonMasterId"].ToString());
                    ht_param.Add("@Contact_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ht_param.Add("@PayScheduleNo", ht["PayScheduleNo"].ToString());
                    ht_param.Add("@CreditedAmount", ht["CreditedAmount"].ToString());
                    ht_param.Add("@EstimatedAmount", ht["EstimatedAmount"].ToString());
                    ht_param.Add("@ORDER_NUMBER", ht["ORDER_NUMBER"].ToString());
                    ht_param.Add("@Attatchments", ht["Attatchments"].ToString());
                    ht_param.Add("@Subject", ht["Subject"].ToString());
                    ht_param.Add("@Comments", ht["Comments"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[TicketQuery_Insert]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Save"] = serializer.Serialize(_UserSaveModel);
                }


                _ErrorModel.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "sucess";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _ErrorModel.Clear();
                ReturnData.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
        public static Hashtable CustomerDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    words = null;
                    words = Req.Split('@');
                    for (int m = 0; words.Count() > m; m++)
                    {
                        Data = words[m].ToString();

                        if (Data == "Country")
                        {
                            _CountryModel.Clear();
                            ht_param.Clear();
                            ds = db.SysFetchDataInDataSet("[GetCountryList]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                foreach (DataRow item in ds.Tables[0].Rows)
                                {
                                    CountryModel CountryModel_Detail = new CountryModel();
                                    CountryModel_Detail.Name       = item["NAME"].ToString();
                                    CountryModel_Detail.COUNTRY_ID = Convert.ToInt32(item["COUNTRY_ID"].ToString());
                                    _CountryModel.Add(CountryModel_Detail);
                                }
                            }
                            ReturnData["Country"] = serializer.Serialize(_CountryModel);


                            GetStateforDefaultCountry(_CountryModel[0].COUNTRY_ID.ToString());
                        }
                        if (Data == "Fill1")
                        {
                            _CountryModel.Clear();
                            _CustomerDetailsModel.Clear();
                            ht_param.Clear();
                            ht_param.Add("@ID", ht["ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[GetSelectedCustomerDetails]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                _CustomerDetailsModel = ds.Tables[0].AsEnumerable()
                                                        .Select(row => new CustomerDetailsModel
                                {
                                    ID                  = row["ID"].ToString(),
                                    Company_Name        = row["Company_Name"].ToString(),
                                    Account_Number      = row["Account_Number"].ToString(),
                                    Country             = row["Country"].ToString(),
                                    State               = row["State"].ToString(),
                                    City                = row["City"].ToString(),
                                    Zip_Code            = row["Zip_Code"].ToString(),
                                    Address1            = row["Address1"].ToString(),
                                    Address2            = row["Address2"].ToString(),
                                    Accnt_Payable_Email = row["Accnt_Payable_Email"].ToString(),
                                    IsActive            = row["IsActive"].ToString()
                                }).ToList();
                            }
                            ReturnData["BasicData"] = serializer.Serialize(_CustomerDetailsModel);
                        }
                        if (Data == "ContactDetails")
                        {
                            _CountryModel.Clear();
                            _TruckLocationModel.Clear();
                            ht_param.Clear();
                            ht_param.Add("@BT_ID", ht["ID"].ToString());
                            ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                            ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[GET_CUSTOMER_DETAILS_Contact]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                _TruckLocationModel = ds.Tables[0].AsEnumerable()
                                                      .Select(row => new CustomerContactDetailsModel
                                {
                                    ID           = row["ID"].ToString(),
                                    Contact_Name = row["Contact_Name"].ToString(),
                                    Designation  = row["Designation"].ToString(),
                                    Email        = row["Email"].ToString(),
                                    Phone        = row["Phone"].ToString(),
                                    Fax          = row["Fax"].ToString()
                                }).ToList();
                            }
                            ReturnData["ContactDetails"] = serializer.Serialize(_TruckLocationModel);
                        }
                    }
                }

                if (Type == "State")
                {
                    _CountryModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@COUNTRY_ID", ht["COUNTRY_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[GetStateList]", ht_param);

                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            CountryModel CountryModel_Detail = new CountryModel();
                            CountryModel_Detail.Name       = item["NAME"].ToString();
                            CountryModel_Detail.COUNTRY_ID = Convert.ToInt32(item["LOCATION_ID"].ToString());
                            _CountryModel.Add(CountryModel_Detail);
                        }
                    }
                    ReturnData["State"] = serializer.Serialize(_CountryModel);
                }


                if (Type == "Save")
                {
                    _UserSaveModelWithID.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("@Company_Name", ht["Company_Name"]);
                    ht_param.Add("@Account_Number", ht["Account_Number"]);
                    if (ht["Country"].ToString() == "")
                    {
                        ht_param.Add("@Country", DBNull.Value);
                    }
                    else
                    {
                        ht_param.Add("@Country", ht["Country"].ToString());
                    }

                    if (ht["State"].ToString() == "")
                    {
                        ht_param.Add("@State", DBNull.Value);
                    }
                    else
                    {
                        ht_param.Add("@State", ht["State"].ToString());
                    }
                    ht_param.Add("@City", ht["City"].ToString());
                    ht_param.Add("@Zip_Code", ht["Zip_Code"].ToString());
                    ht_param.Add("@Address1", ht["Address1"].ToString());
                    ht_param.Add("@Address2", ht["Address2"].ToString());
                    ht_param.Add("@Accnt_Payable_Email", ht["Accnt_Payable_Email"].ToString());


                    ht_param.Add("@ContactID", ht["ContactID"].ToString());
                    ht_param.Add("@ContactName", ht["ContactName"].ToString());
                    ht_param.Add("@Designation", ht["Designation"].ToString());
                    ht_param.Add("@ContactEmail", ht["ContactEmail"].ToString());
                    ht_param.Add("@ContactPhoneNo", ht["ContactPhoneNo"].ToString());
                    ht_param.Add("@ContactFax", ht["ContactFax"].ToString());

                    ht_param.Add("@Mode", ht["MODE"].ToString());

                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@Login_user_ID", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[INSERT_CUSTOMER_DETAILS_Basic]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModelWithID _UserSaveModelIDDetails = new UserSaveModelWithID();
                            _UserSaveModelIDDetails.ID = item["ID"].ToString();
                            _UserSaveModelIDDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelIDDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModelWithID.Add(_UserSaveModelIDDetails);
                        }
                    }
                    ReturnData["Save"] = serializer.Serialize(_UserSaveModelWithID);
                }
                if (Type == "Delete")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("@MODE", "DELETE");
                    ht_param.Add("@Login_user_ID", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[INSERT_CUSTOMER_DETAILS_Contact]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Delete"] = serializer.Serialize(_UserSaveModel);
                }

                _ErrorModel.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "sucess";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _ErrorModel.Clear();
                ReturnData.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
        public static Hashtable CompanyDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    _CountryModel.Clear();
                    ht_param.Clear();
                    ds = db.SysFetchDataInDataSet("[GetCompanyList]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        CompanyModel_list = ds.Tables[0].AsEnumerable()
                                            .Select(row => new CompanyModel
                        {
                            ID          = row["ID"].ToString(),
                            CompanyName = row["CompanyName"].ToString(),
                            CEOName     = row["CEOName"].ToString(),
                            MobileNo    = row["MobileNo"].ToString(),
                            PhoneNo     = row["PhoneNo"].ToString(),
                            Email       = row["Email"].ToString(),
                            Country     = row["Country"].ToString(),
                            City        = row["City"].ToString(),
                            State       = row["State"].ToString(),
                            CompanyType = row["CompanyType"].ToString(),
                            Address     = row["Address"].ToString(),
                            WebsiteUrl  = row["WebsiteUrl"].ToString(),
                            LogoPath    = row["LogoPath"].ToString(),
                            IsActive    = row["IsActive"].ToString()
                        }).ToList();
                    }
                    ReturnData["CompanyData"] = serializer.Serialize(CompanyModel_list);
                }

                if (Type == "Delete")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["COMPANY_ID"]);
                    ht_param.Add("@MODE", "DELETE");
                    ht_param.Add("@Login_user_ID", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[INSERT_COMPANY_DETAILS]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["CompanyData"] = serializer.Serialize(_UserSaveModel);
                    //ReturnData["CompanyData"] = serializer.Serialize("deleted successfully.");
                }


                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "Success";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);

                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
Пример #23
0
        public static Hashtable TaxDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    words = null;
                    words = Req.Split('@');
                    for (int m = 0; words.Count() > m; m++)
                    {
                        Data = words[m].ToString();


                        ht_param.Clear();
                        ht_param.Add("@TickerNumber", ht["TickerNumber"].ToString());
                        ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                        ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                        ht_param.Add("@Login_user_ID", HttpContext.Current.Session["Login_user_ID"].ToString());
                        ds = db.SysFetchDataInDataSet("[TicketView_Get]", ht_param);

                        if (ds.Tables.Count > 0)
                        {
                            _ActiveTicketModel = ds.Tables[0].AsEnumerable()
                                                 .Select(row => new ActiveTicketModel
                            {
                                TickerNumber      = row["TickerNumber"].ToString(),
                                TicketDate        = row["TicketDate"].ToString(),
                                TicketLabel       = row["TicketLabel"].ToString(),
                                QueryType         = row["QueryType"].ToString(),
                                Status            = row["Status"].ToString(),
                                PayScheduleNo     = row["PayScheduleNo"].ToString(),
                                CreditedAmount    = row["CreditedAmount"].ToString(),
                                EstimatedAmount   = row["EstimatedAmount"].ToString(),
                                Attatchments      = row["Attatchments"].ToString(),
                                Subject           = row["Subject"].ToString(),
                                ORDER_NUMBER      = row["ORDER_NUMBER"].ToString(),
                                AnsweredBy        = row["AnsweredBy"].ToString(),
                                AssignedTO        = row["AssignedTO"].ToString(),
                                ActionPendingFrom = row["ActionPendingFrom"].ToString(),
                            }).ToList();

                            _ActiveTicketCommentModel = ds.Tables[1].AsEnumerable()
                                                        .Select(row => new ActiveTicketCommentModel
                            {
                                comments = row["comments"].ToString(),
                                Colour   = row["Colour"].ToString()
                            }).ToList();
                        }

                        ReturnData["TicketView"] = serializer.Serialize(_ActiveTicketModel);

                        ReturnData["TicketViewComment"] = serializer.Serialize(_ActiveTicketCommentModel);
                    }
                }

                if (Type == "Save")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@TickerNumber", ht["TickerNumber"].ToString());
                    ht_param.Add("@Comments", ht["Comments"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[TicketQueryDetails_Insert]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Save"] = serializer.Serialize(_UserSaveModel);
                }


                //if (Type == "Update")
                //{
                //    _UserSaveModel.Clear();

                //    ht_param.Clear();
                //    ht_param.Add("@ID", ht["ID"]);
                //    ht_param.Add("@CGST_PERCENTAGE", ht["CGST_PERCENTAGE"].ToString());
                //    ht_param.Add("@SGST_PERCENTAGE", ht["SGST_PERCENTAGE"].ToString());
                //    ht_param.Add("@IGST_PERCENTAGE", ht["IGST_PERCENTAGE"].ToString());
                //    ht_param.Add("@IsActive", ht["IsActive"].ToString());
                //    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                //    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                //    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                //    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_GST]", ht_param);
                //    if (ds.Tables.Count > 0)
                //    {
                //        foreach (DataRow item in ds.Tables[0].Rows)
                //        {
                //            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                //            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                //            _UserSaveModelDetails.CustomMessage = item["CustomMessage"].ToString();
                //            _UserSaveModel.Add(_UserSaveModelDetails);
                //        }
                //    }
                //    ReturnData["Update"] = serializer.Serialize(_UserSaveModel);
                //}



                _ErrorModel.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "sucess";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _ErrorModel.Clear();
                ReturnData.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
        public static Hashtable AllLoadDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    ht_param.Clear();
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[GET_TicketQueryMaster]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        _gstlistModel = ds.Tables[0].AsEnumerable()
                                        .Select(row => new PaymentModelistModel
                        {
                            ID       = row["ID"].ToString(),
                            NAME     = row["NAME"].ToString(),
                            IsActive = row["IsActive"].ToString()
                        }).ToList();
                    }
                    ReturnData["LoadData"] = serializer.Serialize(_gstlistModel);
                }
                if (Type == "setStatus")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("@IsActive", ht["IsActive"]);
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_TicketQueryMaster]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["setStatus"] = serializer.Serialize(_UserSaveModel);
                }

                if (Type == "Delete")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("@IsActive", ht["IsActive"]);
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_TicketQueryMaster]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Delete"] = serializer.Serialize(_UserSaveModel);
                }


                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "Success";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);

                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
        public static Hashtable AllLoadDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    ht_param.Clear();
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[GET_ITEM_DETAILS]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        _gstlistModel = ds.Tables[0].AsEnumerable()
                                        .Select(row => new ItemDetails_ListModel
                        {
                            ID                  = row["ID"].ToString(),
                            CATEGORY_ID         = row["CATEGORY_ID"].ToString(),
                            NAME                = row["NAME"].ToString(),
                            PBO_PRICE           = row["PBO_PRICE"].ToString(),
                            PRODUCT_SVP         = row["PRODUCT_SVP"].ToString(),
                            DISCOUNT_PERCENTAGE = row["DISCOUNT_PERCENTAGE"].ToString(),
                            DISCOUNT_AMOUNT     = row["DISCOUNT_AMOUNT"].ToString(),
                            CODE                = row["CODE"].ToString(),
                            GST_ID              = row["GST_ID"].ToString(),
                            MRP                 = row["MRP"].ToString(),
                            SALE_PRICE          = row["SALE_PRICE"].ToString(),
                            ImageURL            = row["ImageURL"].ToString(),
                            IsActive            = row["IsActive"].ToString(),
                            CATEGORY_NAME       = row["CATEGORY_NAME"].ToString(),
                            IGST_PERCENTAGE     = row["IGST_PERCENTAGE"].ToString(),
                            CGST_PERCENTAGE     = row["CGST_PERCENTAGE"].ToString(),
                            SGST_PERCENTAGE     = row["SGST_PERCENTAGE"].ToString()
                        }).ToList();
                    }
                    ReturnData["LoadData"] = serializer.Serialize(_gstlistModel);
                }
                if (Type == "setStatus")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("@IsActive", ht["IsActive"]);
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_ITEM_DETAILS]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["setStatus"] = serializer.Serialize(_UserSaveModel);
                }

                if (Type == "Delete")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("@IsActive", ht["IsActive"]);
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_ITEM_DETAILS]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Delete"] = serializer.Serialize(_UserSaveModel);
                }


                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "Success";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);

                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
Пример #26
0
        public async Task <HttpResponseMessage> Save(UserSaveModel registerModel)
        {
            var registerDto = _mapper.Map <ManagedUserDto>(registerModel);

            return(await _httpClient.PostAsJsonAsync(RegisterUrl, registerDto));
        }
        public static Hashtable savedetailswithlist(Hashtable ht, string Type, string Req, List <LoadList> LoadList)
        {
            string Data = "";
            string obj  = "";

            Hashtable   ht_param    = new Hashtable();
            Hashtable   ReturnData  = new Hashtable();
            DBFunctions db          = new DBFunctions();
            DataSet     ds          = new DataSet();
            DataSet     ds12        = new DataSet();
            DataTable   dt_LoadList = new DataTable();

            List <ErrorModel> _ErrorDetails = new List <ErrorModel>();

            ReturnData.Clear();
            System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            try
            {
                if (Type == "SaveCompleteLoad")
                {
                    _UserSaveModel.Clear();


                    ht_param.Clear();

                    dt_LoadList = SaveParameters_LoadList(LoadList);
                    ht_param.Add("@UDT_ITEMS_STOCK", dt_LoadList);

                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@Login_user_ID", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_ITEMS_STOCK]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Save"] = serializer.Serialize(_UserSaveModel);
                }

                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "Success";
                _ErrorDetails.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorDetails);

                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";//ex.ToString();
                _ErrorDetails.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorDetails);

                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }


            return(ReturnData);
        }
        public static Hashtable CustomerDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    _CustomerDetailsModel.Clear();
                    ht_param.Clear();
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[GetCustomerDetailsList]", ht_param);

                    if (ds.Tables.Count > 0)
                    {
                        _CustomerDetailsModel = ds.Tables[0].AsEnumerable()
                                                .Select(row => new CustomerDetailsModel
                        {
                            ID                  = row["ID"].ToString(),
                            Company_Name        = row["Company_Name"].ToString(),
                            Account_Number      = row["Account_Number"].ToString(),
                            Country             = row["Country"].ToString(),
                            State               = row["State"].ToString(),
                            City                = row["City"].ToString(),
                            Zip_Code            = row["Zip_Code"].ToString(),
                            Address1            = row["Address1"].ToString(),
                            Address2            = row["Address2"].ToString(),
                            Accnt_Payable_Email = row["Accnt_Payable_Email"].ToString(),
                            IsActive            = row["IsActive"].ToString()
                        }).ToList();
                    }
                    ReturnData["BasicData"] = serializer.Serialize(_CustomerDetailsModel);
                }

                if (Type == "Delete")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    //  ht_param.Add("@MODE", "DELETE");
                    ht_param.Add("@Login_user_ID", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[CustomerDetailsDelete]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["CustomerData"] = serializer.Serialize(_UserSaveModel);
                    //ReturnData["CompanyData"] = serializer.Serialize("deleted successfully.");
                }


                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "Success";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);

                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
Пример #29
0
        public static Hashtable TaxDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    words = null;
                    words = Req.Split('@');
                    for (int m = 0; words.Count() > m; m++)
                    {
                        Data = words[m].ToString();
                        if (Data == "Country")
                        {
                            _CountryModel.Clear();
                            ht_param.Clear();
                            ds = db.SysFetchDataInDataSet("[GetCountryList]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                foreach (DataRow item in ds.Tables[0].Rows)
                                {
                                    CountryModel CountryModel_Detail = new CountryModel();
                                    CountryModel_Detail.Name       = item["NAME"].ToString();
                                    CountryModel_Detail.COUNTRY_ID = Convert.ToInt32(item["COUNTRY_ID"].ToString());
                                    _CountryModel.Add(CountryModel_Detail);
                                }
                            }
                            ReturnData["Country"] = serializer.Serialize(_CountryModel);
                        }

                        if (Data == "Edit")
                        {
                            ht_param.Clear();
                            ht_param.Add("@ID", ht["ID"].ToString());
                            ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                            ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                            ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[GET_SHIPPING_CHARGES]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                _gstModel = ds.Tables[0].AsEnumerable()
                                            .Select(row => new ShippingChargesModel
                                {
                                    ID                = row["ID"].ToString(),
                                    DISTRICT_ID       = row["DISTRICT_ID"].ToString(),
                                    CHARGE_PERCENTAGE = row["CHARGE_PERCENTAGE"].ToString(),
                                    CHARGE_AMOUNT     = row["CHARGE_AMOUNT"].ToString(),
                                    DISTRICT_NAME     = row["DISTRICT_NAME"].ToString(),
                                    country_id        = row["country_id"].ToString(),
                                    state_id          = row["state_id"].ToString(),
                                    IsActive          = row["IsActive"].ToString()
                                }).ToList();
                            }

                            ReturnData["TaxData"] = serializer.Serialize(_gstModel);
                        }
                    }
                }
                if (Type == "State")
                {
                    _CountryModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@COUNTRY_ID", ht["COUNTRY_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[GetStateList]", ht_param);

                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            CountryModel CountryModel_Detail = new CountryModel();
                            CountryModel_Detail.Name       = item["NAME"].ToString();
                            CountryModel_Detail.COUNTRY_ID = Convert.ToInt32(item["LOCATION_ID"].ToString());
                            _CountryModel.Add(CountryModel_Detail);
                        }
                    }
                    ReturnData["State"] = serializer.Serialize(_CountryModel);
                }
                if (Type == "District")
                {
                    _CountryModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@State_ID", ht["State_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[GetDistrictList]", ht_param);

                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            CountryModel CountryModel_Detail = new CountryModel();
                            CountryModel_Detail.Name       = item["NAME"].ToString();
                            CountryModel_Detail.COUNTRY_ID = Convert.ToInt32(item["DISTRICT_ID"].ToString());
                            _CountryModel.Add(CountryModel_Detail);
                        }
                    }
                    ReturnData["District"] = serializer.Serialize(_CountryModel);
                }
                if (Type == "Save")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@CHARGE_PERCENTAGE", ht["CHARGE_PERCENTAGE"].ToString());
                    ht_param.Add("@CHARGE_AMOUNT", ht["CHARGE_AMOUNT"].ToString());
                    ht_param.Add("@DISTRICT_ID", ht["DISTRICT_ID"].ToString());
                    ht_param.Add("@IsActive", ht["IsActive"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_SHIPPING_CHARGES]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Save"] = serializer.Serialize(_UserSaveModel);
                }


                if (Type == "Update")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("@CHARGE_PERCENTAGE", ht["CHARGE_PERCENTAGE"].ToString());
                    ht_param.Add("@CHARGE_AMOUNT", ht["CHARGE_AMOUNT"].ToString());
                    ht_param.Add("@DISTRICT_ID", ht["DISTRICT_ID"].ToString());
                    ht_param.Add("@IsActive", ht["IsActive"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_SHIPPING_CHARGES]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Update"] = serializer.Serialize(_UserSaveModel);
                }



                _ErrorModel.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "sucess";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _ErrorModel.Clear();
                ReturnData.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
        public static Hashtable TaxDetails(Hashtable ht, string Type, string Req)
        {
            try
            {
                string[] words = null;
                string   Data  = Req;

                ReturnData.Clear();

                if (Type == "Fill")
                {
                    words = null;
                    words = Req.Split('@');
                    for (int m = 0; words.Count() > m; m++)
                    {
                        Data = words[m].ToString();


                        if (Data == "Edit")
                        {
                            ht_param.Clear();
                            ht_param.Add("@ID", ht["ID"].ToString());
                            ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                            ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                            ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[GET_GST]", ht_param);

                            if (ds.Tables.Count > 0)
                            {
                                _gstModel = ds.Tables[0].AsEnumerable()
                                            .Select(row => new gstModel
                                {
                                    ID   = row["ID"].ToString(),
                                    CGST = row["CGST_PERCENTAGE"].ToString(),
                                    SGST = row["SGST_PERCENTAGE"].ToString(),
                                    IGST = row["IGST_PERCENTAGE"].ToString()
                                }).ToList();
                            }

                            ReturnData["TaxData"] = serializer.Serialize(_gstModel);
                        }
                    }
                }

                if (Type == "Save")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@CGST_PERCENTAGE", ht["CGST_PERCENTAGE"].ToString());
                    ht_param.Add("@SGST_PERCENTAGE", ht["SGST_PERCENTAGE"].ToString());
                    ht_param.Add("@IGST_PERCENTAGE", ht["IGST_PERCENTAGE"].ToString());
                    ht_param.Add("@IsActive", ht["IsActive"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_GST]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Save"] = serializer.Serialize(_UserSaveModel);
                }


                if (Type == "Update")
                {
                    _UserSaveModel.Clear();

                    ht_param.Clear();
                    ht_param.Add("@ID", ht["ID"]);
                    ht_param.Add("@CGST_PERCENTAGE", ht["CGST_PERCENTAGE"].ToString());
                    ht_param.Add("@SGST_PERCENTAGE", ht["SGST_PERCENTAGE"].ToString());
                    ht_param.Add("@IGST_PERCENTAGE", ht["IGST_PERCENTAGE"].ToString());
                    ht_param.Add("@IsActive", ht["IsActive"].ToString());
                    ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                    ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                    ht_param.Add("@login_id", HttpContext.Current.Session["Login_user_ID"].ToString());
                    ds = db.SysFetchDataInDataSet("[SAVE_UPDATE_GST]", ht_param);
                    if (ds.Tables.Count > 0)
                    {
                        foreach (DataRow item in ds.Tables[0].Rows)
                        {
                            UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                            _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                            _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                            _UserSaveModel.Add(_UserSaveModelDetails);
                        }
                    }
                    ReturnData["Update"] = serializer.Serialize(_UserSaveModel);
                }



                _ErrorModel.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "sucess";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _ErrorModel.Clear();
                ReturnData.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _ErrorModel.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_ErrorModel);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }
        public static Hashtable RoleDetailsList(Hashtable ht, string Type, string Req)
        {
            try
            {
                string Data = Req;
                RoleModel_list.Clear();
                ReturnData.Clear();

                if (Type == "Fill")
                {
                    if (Data == "GetPermissionList")
                    {
                        dictionary = new Dictionary <string, object>();
                        ht_param.Clear();
                        ht_param.Add("@Roll_Id", ht["roleid"].ToString());
                        ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                        ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                        ds = db.SysFetchDataInDataSet("[GET_PERMISSION_DETAILS]", ht_param);
                        if (ds.Tables.Count > 0)
                        {
                            PermissionModel_list = ds.Tables[0].AsEnumerable()
                                                   .Select(row => new PermissionModel
                            {
                                Permission_ID = row["Permission_ID"].ToString(),
                                MenuID        = row["MenuID"].ToString(),
                                Role_ID       = row["RoleID"].ToString(),
                                MenuName      = row["MenuName"].ToString(),
                                B_Add         = row["B_Add"].ToString(),
                                B_Edit        = row["B_Edit"].ToString(),
                                B_Delete      = row["B_Delete"].ToString(),
                                B_View        = row["B_View"].ToString(),
                                B_Payment     = row["B_Payment"].ToString(),
                                Role_Name     = row["RoleName"].ToString()
                            }).ToList();
                        }
                        serializer.MaxJsonLength = 1000000000;
                        dictionary.Add("data", PermissionModel_list);
                        ReturnData["GetPermissionList"] = serializer.Serialize(dictionary);
                    }
                }


                if (Type == "Insert")
                {
                    if (Data == "SaveAllMenuPermission")
                    {
                        ht_param.Clear();
                        string PermissionID = ht["PermissionID"].ToString();
                        string MenuID       = ht["MenuID"].ToString();
                        string B_Add        = ht["B_Add"].ToString();
                        string B_Edit       = ht["B_Edit"].ToString();
                        string B_Delete     = ht["B_Delete"].ToString();
                        string B_View       = ht["B_View"].ToString();
                        string B_Payment    = ht["B_Payment"].ToString();
                        string Role_ID      = ht["roleid"].ToString();

                        char[]   splitchar     = { ',' };
                        string[] menuidArr     = MenuID.Split(splitchar);
                        string[] purchaseidArr = PermissionID.Split(splitchar);
                        string[] add           = B_Add.Split(splitchar);
                        string[] edit          = B_Edit.Split(splitchar);
                        string[] delete        = B_Delete.Split(splitchar);
                        string[] view          = B_View.Split(splitchar);
                        string[] payment       = B_Payment.Split(splitchar);

                        string[] _count = menuidArr.Where(x => !string.IsNullOrEmpty(x)).ToArray();
                        int      count  = _count.Count();
                        List <PermissionModel> _permissionModel = new List <PermissionModel>();
                        for (int i = 0; count > i; i++)
                        {
                            ht_param.Clear();
                            ht_param.Add("@ID", purchaseidArr[i].ToString());
                            ht_param.Add("@MenuID", menuidArr[i].ToString());
                            ht_param.Add("@RoleID", Role_ID);
                            ht_param.Add("@B_Add", add[i].ToString() == "true" ? 1 : 0);
                            ht_param.Add("@B_Edit", edit[i].ToString() == "true" ? 1 : 0);
                            ht_param.Add("@B_Delete", delete[i].ToString() == "true" ? 1 : 0);
                            ht_param.Add("@B_View", view[i].ToString() == "true" ? 1 : 0);
                            ht_param.Add("@B_Payment", payment[i].ToString() == "true" ? 1 : 0);
                            ht_param.Add("@Company_ID", HttpContext.Current.Session["Company_ID"].ToString());
                            ht_param.Add("@Branch_ID", HttpContext.Current.Session["Branch_ID"].ToString());
                            ds = db.SysFetchDataInDataSet("[CU_PERMISSION]", ht_param);
                            if (ds.Tables.Count > 0)
                            {
                                foreach (DataRow item in ds.Tables[0].Rows)
                                {
                                    UserSaveModel _UserSaveModelDetails = new UserSaveModel();
                                    _UserSaveModelDetails.CustomErrorState = item["CustomErrorState"].ToString();
                                    _UserSaveModelDetails.CustomMessage    = item["CustomMessage"].ToString();
                                    _UserSaveModel.Add(_UserSaveModelDetails);
                                }
                            }
                            ReturnData["SaveAllMenuPermission"] = serializer.Serialize(_UserSaveModel);
                        }
                        //ReturnData["SaveAllMenuPermission"] = "success";
                    }
                }

                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "false";
                _error.ErrorMessage = "Success";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);

                HttpContext.Current.Response.AppendHeader("ResponseHeader", "200");
            }
            catch (Exception ex)
            {
                _errorDetail.Clear();
                ErrorModel _error = new ErrorModel();
                _error.Error        = "true";
                _error.ErrorMessage = "Some problem occurred please try again later";
                _errorDetail.Add(_error);
                ReturnData["ErrorDetail"] = serializer.Serialize(_errorDetail);
                HttpContext.Current.Response.AppendHeader("ResponseHeader", "500");
            }
            return(ReturnData);
        }