Exemplo n.º 1
0
        public async Task <IActionResult> UpdateUser([FromBody] VW_UserDetail vw_UserDetail)
        {
            var Transaction = _repo.BeginTrainsaction();

            try
            {
                await _repo.userCreationCRUD.UpdateUser(vw_UserDetail);

                await _repo.vsecLoginMst.UpdateLogin(vw_UserDetail);

                Transaction.Commit();

                return(NoContent());
            }
            catch (Exception ex)
            {
                Transaction.Rollback();
                _logger.LogError($"Something went wrong inside UpdateUser action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
            finally
            {
                Transaction.Dispose();
            }
        }
Exemplo n.º 2
0
        public async Task UpdateUser(VW_UserDetail vw_userdetail)
        {
            VsecUserMst vsec_user_mst = new VsecUserMst
            {
                UserMstId  = vw_userdetail.UserMstID,
                FirstName  = vw_userdetail.FirstName,
                MiddleName = vw_userdetail.MiddleName,
                LastName   = vw_userdetail.LastName,
                FatherName = vw_userdetail.FatherName,
                Dob        = vw_userdetail.DOB,
                Gender     = vw_userdetail.Gender,
                Email      = vw_userdetail.Email,
                Address1   = vw_userdetail.Address1,
                Address2   = vw_userdetail.Address2,
                Address3   = vw_userdetail.Address3,
                ContactNo  = vw_userdetail.ContactNo,
                Status     = vw_userdetail.Status,
                McStatus   = vw_userdetail.Status,
                CreatedBy  = vw_userdetail.CreatedBy,
                CreatedOn  = DateTime.Now,
                P1         = vw_userdetail.P1
            };

            Update(vsec_user_mst);
            await SaveAsync();
        }
Exemplo n.º 3
0
        public async Task <IActionResult> CreateUser([FromBody] VW_UserDetail vw_UserDetail)
        {
            var Transaction = _repo.BeginTrainsaction();

            try
            {
                await _repo.userCreationCRUD.CreateUser(vw_UserDetail);

                vw_UserDetail.UserMstID = _repo.userCreationCRUD.MaxUserMstID().Result;
                await _repo.vsecLoginMst.CreatLogin(vw_UserDetail);

                Transaction.Commit();

                return(CreatedAtRoute("UserById", new { id = vw_UserDetail.UserMstID }, vw_UserDetail));
            }
            catch (Exception ex)
            {
                Transaction.Rollback();
                _logger.LogError($"Something went wrong inside CreateUser action: {ex.Message}");
                return(StatusCode(500, "Internal server error"));
            }
            finally
            {
                Transaction.Dispose();
            }
        }
Exemplo n.º 4
0
 public VW_UserDetail GetUserByID(int ID)
 {
     try
     {
         VW_UserDetail vw_usedetail = _db.VW_UserDetail.Where(r => r.UserMstID == ID).SingleOrDefault();
         return(vw_usedetail);
     }
     catch (Exception e)
     {
         throw;
     }
 }
Exemplo n.º 5
0
        public async Task UpdateLogin(VW_UserDetail vw_userdetail)
        {
            VsecLoginMst vsecLoginMst = new VsecLoginMst
            {
                LoginMid     = vw_userdetail.LoginMId,
                LoginId      = vw_userdetail.LoginID,
                ProfileId    = vw_userdetail.ProfileId,
                ActiveStatus = vw_userdetail.Status,
                Password     = vw_userdetail.RPassword,
                CreatedBy    = vw_userdetail.CreatedBy,
                CreatedOn    = DateTime.Now
            };

            Update(vsecLoginMst);
            await SaveAsync();
        }
Exemplo n.º 6
0
        // GET: UserCRUD
        public JsonResult UpdateUser(VW_UserDetail vw_userdetail)
        {
            try
            {
                string Message = string.Empty;
                bool   flag    = false;
                try
                {
                    if (vw_userdetail != null)
                    {
                        string LoginID = string.Empty;
                        GVObjDict = new Dictionary <string, string>();
                        GVObjDict = (Dictionary <string, string>)Session["GMVSession"];
                        GVObjDict.TryGetValue("LoginID", out LoginID);

                        vw_userdetail.CreatedBy = LoginID;

                        _IVW_UserDetail.UpdateUser(vw_userdetail);

                        Message = "User updated Successfully";
                        flag    = true;
                    }
                    else
                    {
                        return(Json("Failed"));
                    }
                }
                catch (Exception)
                {
                    Message = "User update failed! Please try again";
                }
                return(new JsonResult {
                    Data = new { Message = Message, Status = flag }
                });
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemplo n.º 7
0
        public void CreatUser(VW_UserDetail vw_userdetail)
        {
            try
            {
                if (vw_userdetail != null)
                {
                    VSEC_USER_MST vsec_user_mst = new VSEC_USER_MST
                    {
                        UserMstID  = _db.VSEC_USER_MST.Max(m => m.UserMstID) + 1,
                        FirstName  = vw_userdetail.FirstName,
                        MiddleName = vw_userdetail.MiddleName,
                        LastName   = vw_userdetail.LastName,
                        FatherName = vw_userdetail.FatherName,
                        DOB        = vw_userdetail.DOB,
                        Gender     = vw_userdetail.Gender,
                        Email      = vw_userdetail.Email,
                        Address1   = vw_userdetail.Address1,
                        Address2   = vw_userdetail.Address2,
                        Address3   = vw_userdetail.Address3,
                        ContactNo  = vw_userdetail.ContactNo,
                        Status     = vw_userdetail.Status == "true" ? "A" : "D",
                        MC_Status  = vw_userdetail.Status == "true" ? "A" : "D",
                        CreatedBy  = vw_userdetail.CreatedBy,
                        CreatedOn  = DateTime.Now,
                        P1         = vw_userdetail.P1
                    };

                    VSEC_LOGIN_MST vsec_login_mst = new VSEC_LOGIN_MST
                    {
                        LoginMId     = 0,
                        LoginID      = vw_userdetail.LoginID,
                        ProfileId    = vw_userdetail.ProfileId,
                        ActiveStatus = vw_userdetail.Status == "true" ? "Y" : "N",
                        Password     = vw_userdetail.RPassword,
                        CreatedBy    = vw_userdetail.CreatedBy,
                        CreatedOn    = DateTime.Now
                    };

                    _db.VSEC_USER_MST.Add(vsec_user_mst);

                    using (System.Data.Entity.DbContextTransaction dbTran = _db.Database.BeginTransaction())
                    {
                        try
                        {
                            _db.SaveChanges();

                            vsec_login_mst.UserMstID = _db.VSEC_USER_MST.Max(m => m.UserMstID);
                            _db.VSEC_LOGIN_MST.Add(vsec_login_mst);

                            _db.SaveChanges();

                            dbTran.Commit();
                        }
                        catch (System.Data.Entity.Validation.DbEntityValidationException e)
                        {
                            dbTran.Rollback();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                throw;
            }
        }