public IHttpActionResult SetPrivileges(int?UserId, List <Modulesmodels> model)
        {
            var response             = new DataResponse <VMPrivilege>();
            List <Privileges> entity = new List <Privileges>();

            foreach (var module in model)
            {
                foreach (var privilege in module.UserPrivileges)
                {
                    if (privilege.Id != 0)
                    {
                        entity.Add(new Privileges
                        {
                            UserId     = UserId.Value,
                            Id         = privilege.Id,
                            Name       = privilege.Name,
                            Deny       = privilege.Deny,
                            businessId = CurrentBusinessId
                        });
                    }
                }
            }

            response = repository.SetPrivileges(entity, UserId.Value, CurrentBusinessId.Value);
            if (response.Status == DataResponseStatus.OK)
            {
                //Privilege mail
                if (response.Model != null)
                {
                    var RootPath  = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
                    var ReturnUrl = ConfigurationManager.AppSettings["BaseUrl"] + CurrentUser.RelativeUrl.Replace(" ", "-");

                    string Subject = string.Empty;
                    if (response.Model.UserPrivilegesList != null && response.Model.UserPrivileges.Count() > 0)
                    {
                        Subject = "Privileges";
                    }
                    else
                    {
                        Subject = "Privilege";
                    }

                    //Building an HTML string.
                    StringBuilder html  = new StringBuilder();
                    int           index = 1;
                    foreach (var item in response.Model.UserPrivilegesList)
                    {
                        //UserDepartments = string.Join("<br/>", response.Model.UserDepartmentName);
                        html.Append("<tr><td style = border:1px solid #f0f0f0;border-width:1px 0;padding:11px 0;vertical-align:baseline>" +
                                    "<div style = margin: 0 12px 0 0;border :2px solid #e6e6e6;border-radius :10px 31px;padding :7px 12px;background :#f5f5f5;>");
                        html.Append(index);
                        html.Append("</div>" +
                                    "</td>" +
                                    "<td style = border:1px solid #f0f0f0;border-width:1px 0;padding:11px 0;width:100%>" +
                                    "<div style =font-family:Roboto-Regular,Helvetica,Arial,sans-serif;font-size:13px;color:#202020;line-height:1.5;font-weight:bold>");
                        html.Append(item.Title);
                        html.Append("</div>" +
                                    "<div style = font-family:Roboto-Regular,Helvetica,Arial,sans-serif;font-size:13px;color:#202020;line-height:1.5>");
                        html.Append(item.Description);
                        html.Append("</div>" +
                                    "</td>" +
                                    " </tr>");
                        index++;
                    }

                    string AssignedUserName = response.Model.UserName;
                    var    mail             = new GMEmail();

                    string emailBody = TemplateManager.AddPrivilegesToUser(RootPath, Subject, AssignedUserName, html.ToString(), CurrentUser.FirstName, ReturnUrl);
                    mail.SendDynamicHTMLEmail(response.Model.Email, "New Privilege Added", emailBody, "", "");
                }
            }
            return(Ok <DataResponse>(response));
        }