public IHttpActionResult UpdateSection([FromBody] Section section)
        {
            DataBind data = activities.SaveUpdateSection(section);

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Update", data.dataBefore, data.dataAfter);
            return(Ok("Successfully updated " + section.SectionName));
        }
        public IHttpActionResult UpdateEmployee([FromBody] Employee employee)
        {
            DataBind data = activities.SaveUpdateEmployee(employee);

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Update", data.dataBefore, data.dataAfter);
            return(Ok("Successfully Updated Employee info"));
        }
        public IHttpActionResult UpdateDepartment([FromBody] Department department)
        {
            DataBind data = activities.SaveUpdateDepartment(department);

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Update", data.dataBefore, data.dataAfter);
            return(Ok("Successfully updated " + department.Name));
        }
        public IHttpActionResult UpdateRolePermission([FromBody] RoleWisePermission rolePermission)
        {
            DataBind data = activities.SaveUpdateRolePermission(rolePermission);

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Update", data.dataBefore, data.dataAfter);
            return(Ok("Successfully updated Role Permission"));
        }
        public IHttpActionResult UpdateGroup([FromBody] Group group)
        {
            DataBind data = activities.SaveUpdateGroup(group);

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Update", data.dataBefore, data.dataAfter);
            return(Ok("Successfully updated " + group.GroupName));
        }
Esempio n. 6
0
        public IHttpActionResult SaveDesignation([FromBody] Designation designation)
        {
            DataBind data = activities.SaveUpdateDesignation(designation);

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Insert", data.dataBefore, data.dataAfter);
            return(Ok("Successfully added " + designation.DesignationName));
        }
        public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
        {
            var userManager = context.OwinContext.GetUserManager <ApplicationUserManager>();

            ApplicationUser user = await userManager.FindAsync(context.UserName, context.Password);

            if (user == null)
            {
                context.SetError("invalid_grant", "The Employee Id or password is incorrect.");
                return;
            }

            ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                OAuthDefaults.AuthenticationType);

            ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager,
                                                                                  CookieAuthenticationDefaults.AuthenticationType);

            LogicActivity logic = new LogicActivity();

            AuditTrialReport.SaveAuditReport(user.UserName, "Login", null, null);

            AuthenticationProperties properties = CreateProperties(logic.getUserName(user.UserName), user.UserName);
            AuthenticationTicket     ticket     = new AuthenticationTicket(oAuthIdentity, properties);

            context.Validated(ticket);
            context.Request.Context.Authentication.SignIn(cookiesIdentity);
        }
        public async Task <IHttpActionResult> AccountRegistration([FromBody] RegisterBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = new ApplicationUser()
            {
                UserName = model.EmployeeId, Email = model.Email
            };

            IdentityResult result = await UserManager.CreateAsync(user, "123456789");

            if (!result.Succeeded)
            {
                return(BadRequest("Employee is already registerd"));
            }

            var Acc = new { userId = user.Id, EmployeeId = model.EmployeeId, Email = model.Email };

            var dataAfter = JsonConvert.SerializeObject(Acc);

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Account Register", null, dataAfter);


            return(Ok("Successfully account Registration with default password"));
        }
        public IHttpActionResult UpdateRoles([FromBody] Roles role)
        {
            DataBind data = activities.SaveUpdateRole(role);

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Insert", data.dataBefore, data.dataAfter);
            return(Ok("Successfully updated " + role.RoleName));
        }
        public IHttpActionResult UpdateCustomer([FromBody] Customer customer)
        {
            DataBind data = activities.SaveUpdateCustomer(customer);

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Update", data.dataBefore, data.dataAfter);
            return(Ok("Successfully updated " + customer.AccHolderName));
        }
Esempio n. 11
0
        public IHttpActionResult SaveTransaction([FromBody] Transaction transaction)
        {
            transaction.EmployeeId = User.Identity.Name;
            DataBind data = activities.SaveUpdateTransaction(transaction);

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Transaction", data.dataBefore, data.dataAfter);
            return(Ok("Successfully transaction"));
        }
        public async Task <IHttpActionResult> Register([FromBody] RegisterEmployee model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = new ApplicationUser()
            {
                UserName = model.EmployeeId, Email = model.Email
            };

            IdentityResult result = await UserManager.CreateAsync(user, "123456789");

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }

            try
            {
                SaveUpdateActivities activity = new SaveUpdateActivities();
                LogicActivity        logic    = new LogicActivity();
                DataBind             da       = activity.SaveUpdateEmployee(new Employee
                {
                    EmployeeId    = model.EmployeeId,
                    EmployeeName  = model.EmployeeName,
                    DesignationId = model.DesignationId,
                    SectionId     = model.SectionId,
                    Email         = model.Email,
                    JoiningDate   = model.JoiningDate,
                    ReportTo      = model.ReportTo,
                    Location      = model.Location,
                    GroupName     = model.GroupId,
                    RoleId        = model.RoleId
                });

                UserManager.AddToRoles(user.Id, model.AccessPermission.ToArray());

                var beforData = logic.getEmployee(model.EmployeeId, model.AccessPermission.ToArray());

                var dataAfter = new { Info = beforData, AccessList = model.AccessPermission };

                string data = JsonConvert.SerializeObject(dataAfter);


                AuditTrialReport.SaveAuditReport(User.Identity.Name, "Insert", null, data);
            }
            catch (Exception ev)
            {
                return(BadRequest(ev.ToString()));
            }

            return(Ok("Successfully added Employee with default password"));
        }
 public IHttpActionResult UpdateBranch([FromBody] Branch branch)
 {
     try
     {
         DataBind data = activities.SaveUpdateBranch(branch);
         AuditTrialReport.SaveAuditReport(User.Identity.Name, "Update", data.dataBefore, data.dataAfter);
     }
     catch
     {
         return(BadRequest("Swift Code is already assigned to Others"));
     }
     return(Ok("Successfully updated " + branch.BranchName));
 }
        private AuditTrialReport CreateAuditTrailReport(long sobId, DateTime fromDate, DateTime toDate)
        {
            List <AuditTrailModel> modelList = mapAuditTrialModel(service.AuditTrail(AuthenticationHelper.User.CompanyId, sobId, fromDate, toDate));
            AuditTrialReport       report    = new AuditTrialReport();

            report.Parameters["CompanyName"].Value = companyService
                                                     .GetSingle(AuthenticationHelper.User.CompanyId.ToString(),
                                                                AuthenticationHelper.User.CompanyId).Name;
            report.Parameters["SOBId"].Value    = sobId;
            report.Parameters["FromDate"].Value = fromDate;
            report.Parameters["ToDate"].Value   = toDate;
            report.DataSource = modelList;
            return(report);
        }
        public async Task <IHttpActionResult> ChangePassword(ChangePasswordBindingModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Password is not match"));
            }

            IdentityResult result = await UserManager.ChangePasswordAsync(User.Identity.GetUserId(), model.OldPassword,
                                                                          model.NewPassword);

            if (!result.Succeeded)
            {
                return(BadRequest("Internal Server Problem"));
            }

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Change Password", null, null);

            return(Ok("Password change successfull"));
        }
        public async Task <IHttpActionResult> UpdateUserRole([FromBody] UserRoles model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Provide Proper Information"));
            }

            SaveUpdateActivities activities = new SaveUpdateActivities();



            var user = UserManager.FindByName(model.EmployeeId);

            if (user == null)
            {
                return(BadRequest("The User is not registered"));
            }


            DataBind Roledata = activities.SaveUpdateUserRole(model);
            DataBind data     = new DataBind();

            string[] oldRoles = new List <string>(UserManager.GetRoles(user.Id)).ToArray();
            await UserManager.RemoveFromRolesAsync(user.Id, oldRoles);

            var data1 = new { EmployeeId = user.UserName, Role = Roledata.dataBefore, AccessList = oldRoles };

            data.dataBefore = JsonConvert.SerializeObject(data1);



            await UserManager.AddToRolesAsync(user.Id, model.PermissionName);

            var data2 = new { EmployeeId = user.UserName, Role = Roledata.dataAfter, AccessList = model.PermissionName };

            data.dataAfter = JsonConvert.SerializeObject(data2);

            AuditTrialReport.SaveAuditReport(User.Identity.Name, "Update", data.dataBefore, data.dataAfter);

            return(Ok("Successfully added user permission"));
        }
 public IHttpActionResult Logout()
 {
     AuditTrialReport.SaveAuditReport(User.Identity.Name, "Logout", null, null);
     return(Ok());
 }