Ejemplo n.º 1
0
        public Object GetUser(int page, int pagesize, int userId)
        {
            try
            {
                User user = _CacheManager.GetOrSetUserSession(Request.Query["key"], null);

                var resp = _context.User.Include(r => r.lstUserCorporate)
                           .Include(x => x.lstUserLocation)
                           .Include(x => x.Supervisor)
                           .Where(x => x.UserType != "Admin" && x.UserType != "Supervisor" && x.IsActive &&
                                  user.lstUserLocation.Any(M => x.lstUserCorporate.Any(y => y.CorporateMaster.fk_LocationId == M.FK_LocationId))
                                  )
                           .Select(x => new
                {
                    x.Id,
                    x.UserType,
                    x.IsActive,
                    x.Name,
                    x.EmpCode,
                    Supervisor = x.Supervisor.Name,
                }).GetPaged(page, pagesize);

                var TotalRecords = resp.RowCount;
                return(StatusCode(200, new { TotalRecords, resp }));
            }
            catch (Exception ex)
            {
                _ErrLogService.Log(ex, HttpContext);
                return(StatusCode(500, new { status = true, Msg = ex.Message }));
            }
        }
Ejemplo n.º 2
0
 public Object GetUser(int page, int pagesize, int userid)
 {
     try
     {
         // var resp = _context.Corporate.Where(x => x.OstSubmittedBy == userid)
         //.Select(x => new
         //{
         //    x.Id,
         //    OstSubmittedOn = (x.OstSubmittedOn != null) ? ((DateTime)x.OstSubmittedOn).ToString("dd MMM yyyy hh:mm") : null,
         //    x.Name,
         //    x.No_,
         //    //toDate = (x.toDate != null) ? ((DateTime)x.toDate).ToString("dd MMM yyyy") : null,
         //    //fromDate = (x.fromDate != null) ? ((DateTime)x.fromDate).ToString("dd MMM yyyy") : null,
         //    //x.Amount,
         //}).GetPaged(page, pagesize);
         // var TotalRecords = _context.User.Include(x => x.Supervisor).Where(x => x.UserType != "Admin").Count();
         // return StatusCode(200, new { TotalRecords, resp });
         return(null);
     }
     catch (Exception ex)
     {
         _ErrLogService.Log(ex, HttpContext);
         return(StatusCode(500, new { status = true, Msg = ex.Message }));
     }
 }
        public object GetStatusByUser(int userid, int IsPromise)
        {
            try
            {
                int start = 0; int end = 1;
                if (IsPromise == 0)
                {
                    start = 1;
                    end   = 7;
                }
                var resp1 = _context.UserCorporateAction.Include(x => x.SubmitedCorporate).ThenInclude(x => x.CorporateMaster)
                            .Include(x => x.CorporateStatusMaster).Include(x => x.UserUpdatedBy).Where(x => x.UpdatedBy == userid && x.FK_CorporateStatusMasterId > start && x.FK_CorporateStatusMasterId <= end)
                            .Select(x => new
                {
                    x.Id,
                    x.PromiseAmount,
                    x.PromiseDate,
                    x.UpdatedOn,
                    x.CallNote,

                    Corporate     = x.SubmitedCorporate.CorporateMaster.Name,
                    UserUpdatedBy = x.UserUpdatedBy.Name,
                    Status        = x.CorporateStatusMaster.Name
                });
                return(StatusCode(200, new { resp1 }));
            }
            catch (Exception ex)
            {
                _ErrLogService.Log(ex, HttpContext);
                return(StatusCode(500, new { status = true, Msg = ex.Message }));
            }
        }
Ejemplo n.º 4
0
        public Object GetCorporate(int page, int pagesize, int userId)
        {
            try
            {
                var userLocations = _context.UserLocation.Where(x => x.FK_UserId == userId).Select(x => x.FK_LocationId);
                var resp1         = _context.CorporateMaster.Where(x => userLocations.Contains(x.fk_LocationId))
                                    .Select(x => new
                {
                    x.Id,
                    x.Name,
                    x.Phone,
                    x.Location,
                    x.No_,
                    x.Email
                }).GetPaged(page, pagesize);


                int TotalRecord = resp1.RowCount;
                return(StatusCode(200, new { Results = resp1.Results.OrderBy(x => x.Name), TotalRecord }));
            }
            catch (Exception ex)
            {
                _ErrLogService.Log(ex, HttpContext);
                return(StatusCode(500, new { status = true, Msg = ex.Message }));
            }
        }
 public Object Get()
 {
     try
     {
         var statusList = _context.StatusMaster.Where(x => x.Id != (int)CorporateStatus.Submition).ToList();
         return(Ok(new { status = true, statusList, Msg = "Done!" }));
     }
     catch (Exception ex)
     {
         _ErrLogService.Log(ex, HttpContext, JsonConvert.SerializeObject(ex));
         return(StatusCode(500, new { status = false, Msg = "Internal Server Error!", MsgDetails = ex.Message }));
     }
 }
Ejemplo n.º 6
0
 public Object GetUser(int page, int pagesize)
 {
     try
     {
         var resp = _context.User.Include(x => x.Supervisor).Where(x => x.UserType != "Admin")
                    .Select(x => new
         {
             x.Id,
             x.UserType,
             x.IsActive,
             x.Email,
             x.Name,
             x.EmpCode,
             x.Password,
             Supervisor = x.Supervisor.Name
         }).GetPaged(page, pagesize);
         var TotalRecords = resp.RowCount;
         resp.Results = resp.Results.OrderBy(x => x.Name).ToList();
         return(StatusCode(200, new { TotalRecords, resp }));
     }
     catch (Exception ex)
     {
         _ErrLogService.Log(ex, HttpContext);
         return(StatusCode(500, new { status = true, Msg = ex.Message }));
     }
 }
Ejemplo n.º 7
0
 public object GetFollowupFlag()
 {
     try
     {
         int userId = _cache.GetOrSetUserSession(Request.Query["key"], null).Id;
         var cnt    = _context.UserCorporateAction.Include(x => x.SubmitedCorporate)
                      .Include(x => x.CorporateStatusMaster)
                      .Include(x => x.UserUpdatedBy)
                      .Where(x => x.UpdatedBy == userId && x.CurrentStatus == true && Convert.ToDateTime(x.PromiseDate).Date == DateTime.Now.Date && x.FK_CorporateStatusMasterId == (int)CorporateStatus.Promise).Count();
         return(StatusCode(200, new { status = (cnt > 0) ? true : false }));
     }
     catch (Exception ex)
     {
         _ErrLogService.Log(ex, HttpContext);
         return(StatusCode(500, new { status = false, Msg = ex.Message }));
     }
 }
Ejemplo n.º 8
0
        public IActionResult AuthenticateUser([FromQuery] string empCode, [FromQuery] string password)
        {
            try
            {
                var ss   = _context.User.ToList();
                var resp = _context.User.Include(x => x.lstUserLocation).SingleOrDefault(x => x.EmpCode == empCode && x.Password == password && x.IsActive == true);

                if (resp != null)
                {
                    Guid   obj = Guid.NewGuid();
                    string key = obj.ToString();

                    if (resp.Password != "reset@123")
                    {
                        _CacheManager.GetOrSetUserSession(key, resp);
                        SetCookie("UserData", JsonConvert.SerializeObject(new { resp.Id, resp.UserType, resp.Name }), null);
                        return(Ok(new { CPwdF = false, Status = true, Token = key, resp.UserType, id = resp.Id, resp.Name }));
                    }
                    else
                    {
                        return(StatusCode(200, new { Status = true, id = resp.Id, CPwdF = true, Msg = "Pass" }));
                        // RedirectToAction("ChangePassword");
                        // HttpContext.Response.Redirect("Home/ChangePassword");
                    }
                }
                else
                {
                    return(StatusCode(200, new { Status = true, Msg = "Invalid UserName or Password" }));
                }
            }
            catch (Exception ex)
            {
                _ErrLogService.Log(ex, HttpContext);
                return(StatusCode(500, new { Status = false, MsgDetails = ex.Message, Msg = "Internal Server Error" }));
            }
            return(NoContent());
            //return View("Index");
        }
Ejemplo n.º 9
0
 public Object GetLocationMaster()
 {
     try
     {
         return(_context.LocationMaster.Select(x => new { x.Id, x.BranchLocation, x.Branch }));
     }
     catch (Exception ex)
     {
         _ErrLogService.Log(ex, HttpContext);
         return(StatusCode(500, new { status = true, Msg = ex.Message }));
     }
 }
Ejemplo n.º 10
0
        public object GetStatusByAllUser(int supervisorId)
        {
            try
            {
                var corpLocation = _context.CorporateMaster.Include(x => x.LocationMaster).Select(x => new
                {
                    x.Id,
                    x.Name,
                    x.No_,


                    Location   = x.LocationMaster.BranchLocation,
                    LocationId = x.LocationMaster.Id
                });

                var resp1 = _context.User
                            .Include(x => x.lstUserCorporateAction)
                            .ThenInclude(x => x.CorporateStatusMaster).Where(x => x.fk_SupervisorId == supervisorId).
                            Select(x => new
                {
                    x.Id,
                    x.Name,
                    x.EmpCode,
                    x.Email,
                    lstUserCorporateAction = x.lstUserCorporateAction.Select(m => new
                    {
                        m.Id,
                        m.PromiseAmount,
                        m.PromiseDate,
                        m.UpdatedOn,
                        m.CallNote,
                        LocationName  = corpLocation.SingleOrDefault(h => h.Id == m.FK_SubmitedCorporateId).Location,
                        corporateName = corpLocation.SingleOrDefault(h => h.Id == m.FK_SubmitedCorporateId).Name,
                        Status        = m.CorporateStatusMaster.Name
                    })
                });



                return(StatusCode(200, new { resp1 }));
            }
            catch (Exception ex)
            {
                _ErrLogService.Log(ex, HttpContext);
                return(StatusCode(500, new { status = true, Msg = ex.Message }));
            }
        }
Ejemplo n.º 11
0
 public Object GetEmpData(string empCode)
 {
     try
     {
         var resp = context_Intra.Emp_Data.FirstOrDefault(x => x.emp_status == "N" && x.emp_code == empCode);
         if (resp != null)
         {
             return(Ok(resp));
         }
         else
         {
             return(NoContent());
         }
     }
     catch (Exception ex)
     {
         _ErrLogService.Log(ex, HttpContext);
         return(StatusCode(500, new { status = true, Msg = ex.Message }));
     }
 }
        public async Task <IActionResult> ChangePassword([FromQuery] int id, [FromBody] User user)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                // _context.Attach(user);
                User exist = await _context.Set <User>().FindAsync(id);

                exist.Password = user.Password;
                await _context.SaveChangesAsync();

                return(Ok(new { status = true, Msg = "Password Changed Successfully!" }));
            }
            catch (Exception ex)
            {
                _ErrLogService.Log(ex, HttpContext);
                return(StatusCode(500, new { status = true, Msg = ex.Message }));
            }
        }
Ejemplo n.º 13
0
        public object  SetPriority([FromQuery] int priority, [FromQuery] int CorporateId)
        {
            try
            {
                CorporateMaster Corporate = new CorporateMaster();
                Corporate.Id = CorporateId;

                CorporateMaster CorpMaster = _context.CorporateMaster.SingleOrDefault(x => x.Id == CorporateId);

                CorpMaster.Priority          = (CorpMaster.Priority == 1) ? 0 : 1;
                CorpMaster.PriorityUpdatedBy = _cache.GetOrSetUserSession(Request.Query["key"], null).Id;
                CorpMaster.PrioriyUpdatedOn  = DateTime.Now;

                _context.SaveChanges();

                return(StatusCode(200, new { status = true, CorpMaster.Priority, Msg = "Priority Set Successfully!" }));
            }
            catch (Exception ex)
            {
                _ErrLogService.Log(ex, HttpContext);
                return(StatusCode(500, new { status = true, Msg = "Internal Server Error", MsgDeatail = ex.Message }));
            }
        }
        public async Task <IActionResult> UpdateUserCorporates([FromQuery] int id, [FromBody] List <UserCorporate> userCorporate)
        {
            // Update User Corporate
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            try
            {
                for (int i = 0; i < userCorporate.Count; i++)
                {
                    userCorporate[i].ModifiedBy = id;
                    userCorporate[i].ModifiedOn = DateTime.Now;
                }

                var user = _context.User.Include(x => x.lstUserCorporate).SingleOrDefault(x => x.Id == id);
                user.lstUserCorporate = userCorporate;
                User existUser = await _context.Set <User>().FindAsync(id);

                if (existUser != null)
                {
                    _context.Entry(existUser).CurrentValues.SetValues(user);
                    await _context.SaveChangesAsync();

                    return(StatusCode(200, new { status = true, Msg = "Record Updated!" }));
                }
                else
                {
                    return(StatusCode(200, new { status = false, Msg = "User Not Found!" }));
                }
            }
            catch (Exception ex)
            {
                _ErrLogService.Log(ex, HttpContext);
                return(StatusCode(500, new { status = true, Msg = "Internal Server Error.", MsgDetails = ex.Message }));
            }
        }
Ejemplo n.º 15
0
        public object GetUserCorporate([FromBody] UserReportSearchPara Para)
        {
            try
            {
                if (Para == null)
                {
                    return(StatusCode(400, new { status = false, Msg = "Bad Request" }));
                }

                var UserLogin = _cache.GetOrSetUserSession(Request.Query["key"], null);

                if (UserLogin.UserType.Trim().ToLower() == "supervisor")
                {
                    var userLocation = _context.UserLocation.Include(x => x.Location).Where(x => x.FK_UserId == UserLogin.Id);
                    var Resp         = _context.UserCorporateAction
                                       .Include(x => x.SubmitedCorporate).ThenInclude(y => y.CorporateMaster)
                                       .Include(x => x.CorporateStatusMaster)
                                       .Where(x => x.CurrentStatus == true &&
                                              (Para.userId == 0 || x.UpdatedBy == Para.userId) &&
                                              (x.UpdatedOn.Value.Date >= Para.dtFromDate.Date && x.UpdatedOn.Value.Date <= Para.dtToDate.Date) &&
                                              (Para.ICUST == null || x.SubmitedCorporate.CorporateMaster.No_ == Para.ICUST) &&
                                              (Para.statusId == 0 || x.FK_CorporateStatusMasterId == Para.statusId) &&
                                              userLocation.Any(p => p.Location.Branch == x.SubmitedCorporate.CorporateMaster.Location)
                                              )
                                       .Select(x => new
                    {
                        x.FK_SubmitedCorporateId,
                        x.SubmitedCorporate.CorporateMaster.Name,
                        x.SubmitedCorporate.CorporateMaster.No_,
                        x.SubmitedCorporate.CorporateMaster.Phone,
                        //x.SbmtAmount,
                        //x.PromiseAmount,
                        Amount = ((x.FK_CorporateStatusMasterId) == (int)CorporateStatus.Submition) ? x.SbmtAmount :  x.PromiseAmount,
                        Status = x.CorporateStatusMaster.Name,
                        x.SubmitedCorporate.CorporateMaster.Location,
                        x.UpdatedOn
                    }).GetPaged(Para.Page, Para.PageSize);

                    Resp.Results = Resp.Results.OrderByDescending(x => x.UpdatedOn).ToList();

                    return(StatusCode(200, new { status = true, Resp }));
                }
                else if (UserLogin.UserType.Trim().ToLower() == "calling")
                {
                    var Resp = _context.UserCorporateAction
                               .Include(x => x.SubmitedCorporate).ThenInclude(y => y.CorporateMaster)
                               .Include(x => x.CorporateStatusMaster)
                               .Where(x => x.CurrentStatus == true && x.UpdatedBy == UserLogin.Id &&
                                      (x.UpdatedOn.Value.Date >= Para.dtFromDate.Date && x.UpdatedOn.Value.Date <= Para.dtToDate.Date) &&
                                      (Para.ICUST == null || x.SubmitedCorporate.CorporateMaster.No_ == Para.ICUST) &&
                                      (Para.statusId == 0 || x.FK_CorporateStatusMasterId == Para.statusId)
                                      )
                               .Select(x => new
                    {
                        x.FK_SubmitedCorporateId,
                        x.SubmitedCorporate.CorporateMaster.Name,
                        x.SubmitedCorporate.CorporateMaster.No_,
                        x.SubmitedCorporate.CorporateMaster.Phone,
                        //x.SbmtAmount,
                        //x.PromiseAmount,
                        Amount = ((x.FK_CorporateStatusMasterId) == (int)CorporateStatus.Submition) ? x.SbmtAmount : x.PromiseAmount,
                        Status = x.CorporateStatusMaster.Name,
                        x.SubmitedCorporate.CorporateMaster.Location,
                        x.UpdatedOn
                    }).GetPaged(Para.Page, Para.PageSize);

                    Resp.Results = Resp.Results.OrderByDescending(x => x.UpdatedOn).ToList();

                    return(StatusCode(200, new { status = true, Resp }));
                }
                else if (UserLogin.UserType.Trim().ToLower() == "backoffice")
                {
                    var Resp = _context.UserCorporateAction
                               .Include(x => x.SubmitedCorporate).ThenInclude(y => y.CorporateMaster)
                               .Include(x => x.CorporateStatusMaster)
                               .Where(x => x.UpdatedBy == UserLogin.Id &&
                                      (x.FK_CorporateStatusMasterId == (int)(CorporateStatus.Submition)) &&
                                      (x.UpdatedOn.Value.Date >= Para.dtFromDate.Date && x.UpdatedOn.Value.Date <= Para.dtToDate.Date) &&
                                      (Para.ICUST == null || x.SubmitedCorporate.CorporateMaster.No_ == Para.ICUST)
                                      )
                               .Select(x => new
                    {
                        x.FK_SubmitedCorporateId,
                        x.SubmitedCorporate.CorporateMaster.Name,
                        x.SubmitedCorporate.CorporateMaster.No_,
                        x.SubmitedCorporate.CorporateMaster.Phone,
                        //x.SbmtAmount,
                        //x.PromiseAmount,
                        Amount = ((x.FK_CorporateStatusMasterId) == (int)CorporateStatus.Submition) ? x.SbmtAmount : x.PromiseAmount,
                        Status = x.CorporateStatusMaster.Name,
                        x.SubmitedCorporate.CorporateMaster.Location,
                        x.UpdatedOn
                    }).GetPaged(Para.Page, Para.PageSize);

                    Resp.Results = Resp.Results.OrderByDescending(x => x.UpdatedOn).ToList();

                    return(StatusCode(200, new { status = true, Resp }));
                }

                return(StatusCode(500, new { status = false, Msg = "Invalid User Type" }));
            }
            catch (Exception ex)
            {
                _ErrLogService.Log(ex, HttpContext);
                return(StatusCode(500, new { status = false, Msg = "Internat Server Error!", MsgDetails = ex.Message }));
            }
        }
Ejemplo n.º 16
0
        public Object GetPromisedCorporate(int page, int pagesize, bool IsPromise)
        {
            //int dop = (int)CorporateStatus.Promise;
            try
            {
                int userId = _cache.GetOrSetUserSession(Request.Query["key"], null).Id;

                int TotalRecords = 0;
                if (IsPromise)
                {
                    var statusList = _context.UserCorporateAction.Include(x => x.SubmitedCorporate).ThenInclude(x => x.CorporateMaster)
                                     .Include(x => x.CorporateStatusMaster)
                                     .Include(x => x.UserUpdatedBy)
                                     .Where(x => x.UpdatedBy == userId && x.CurrentStatus == true && x.FK_CorporateStatusMasterId == (int)CorporateStatus.Promise)
                                     .Select(x => new
                    {
                        x.Id,
                        x.PromiseAmount,
                        PromiseDate = (x.PromiseDate != null) ? ((DateTime)x.PromiseDate).ToString("dd MMM yyyy") : null,
                        UpdatedOn   = (x.UpdatedOn != null) ? ((DateTime)x.UpdatedOn).ToString("dd MMM yyyy hh:mm:ss") : null,
                        x.CallNote,
                        x.SubmitedCorporate.Balance,
                        x.FK_SubmitedCorporateId,
                        CorporateName     = x.SubmitedCorporate.CorporateMaster.Name,
                        CorporateLocation = x.SubmitedCorporate.CorporateMaster.Location,
                        CorporateIcust    = x.SubmitedCorporate.CorporateMaster.No_,
                        CorporatePhone    = x.SubmitedCorporate.CorporateMaster.Phone,
                        CorporateEmail    = x.SubmitedCorporate.CorporateMaster.Email,
                        UserUpdatedBy     = x.UserUpdatedBy.Name,
                        Status            = x.CorporateStatusMaster.Name,
                    }).GetPaged(page, pagesize);

                    TotalRecords       = statusList.RowCount;
                    statusList.Results = statusList.Results.OrderByDescending(x => x.UpdatedOn).ToList();
                    return(StatusCode(200, new { statusList.Results, TotalRecords }));
                }
                else
                {
                    var statusList = _context.UserCorporateAction.Include(x => x.SubmitedCorporate).ThenInclude(x => x.CorporateMaster)
                                     .Include(x => x.CorporateStatusMaster)
                                     .Include(x => x.UserUpdatedBy)
                                     .Where(x => x.UpdatedBy == userId && x.CurrentStatus == true && x.FK_CorporateStatusMasterId != (int)CorporateStatus.Promise)
                                     .Select(x => new
                    {
                        x.Id,
                        // x.PromiseAmount,
                        // PromiseDate = (x.PromiseDate != null) ? ((DateTime)x.PromiseDate).ToString("dd MMM yyyy") : null,
                        UpdatedOn = (x.UpdatedOn != null) ? ((DateTime)x.UpdatedOn).ToString("dd MMM yyyy hh:mm:ss") : null,
                        //x.CallNote,
                        //x.Corporate.Balance,
                        x.FK_SubmitedCorporateId,
                        CorporateName     = x.SubmitedCorporate.CorporateMaster.Name,
                        CorporateLocation = x.SubmitedCorporate.CorporateMaster.Location,
                        CorporateIcust    = x.SubmitedCorporate.CorporateMaster.No_,
                        //CorporatePhone = x.Corporate.Phone,
                        CorporateEmail = x.SubmitedCorporate.CorporateMaster.Email,
                        // UserUpdatedBy = x.UserUpdatedBy.Name,
                        Status = x.CorporateStatusMaster.Name
                    }).GetPaged(page, pagesize);

                    TotalRecords       = statusList.RowCount;
                    statusList.Results = statusList.Results.OrderByDescending(x => x.UpdatedOn).ToList();
                    return(StatusCode(200, new { statusList.Results, TotalRecords }));
                }
            }
            catch (Exception ex)
            {
                _ErrLogService.Log(ex, HttpContext);
                return(StatusCode(500, new { status = false, Msg = ex.Message }));
            }
        }