示例#1
0
        public IActionResult Contact([FromServices] ICurrentUsers currentUsers, enmSaveStatus?_enmSaveStatus, enmMessage?_enmMessage)
        {
            mdlContact mdl = new mdlContact();

            if (_enmSaveStatus != null)
            {
                ViewBag.SaveStatus = (int)_enmSaveStatus.Value;
                ViewBag.Message    = _enmMessage?.GetDescription();
            }

            var masterData = _context.TblTcContact.Where(p => p.TcNid == currentUsers.TcNid && !p.Isdeleted).FirstOrDefault();

            if (masterData != null)
            {
                mdl.MobileNo          = masterData.MobileNo;
                mdl.AlternateMobileNo = masterData.AlternateMobileNo;
            }


            return(View(mdl));
        }
示例#2
0
        public async Task <IActionResult> ContactAsync([FromServices] ICurrentUsers currentUsers, mdlContact mdl)
        {
            if (ModelState.IsValid)
            {
                var ExistingData = _context.TblTcContact.FirstOrDefault(p => !p.Isdeleted && p.TcNid == currentUsers.TcNid);
                if (ExistingData != null) // for update the data
                {
                    //ExistingData.Isdeleted = true;
                    ExistingData.MobileNo          = mdl.MobileNo;
                    ExistingData.AlternateMobileNo = mdl.AlternateMobileNo;
                    ExistingData.lastModifiedBy    = currentUsers.TcNid;
                    ExistingData.LastModifieddate  = DateTime.Now;
                    _context.TblTcContact.Update(ExistingData);
                    _context.SaveChanges();
                    return(RedirectToAction("Contact",
                                            new { _enmSaveStatus = enmSaveStatus.success, _enmMessage = enmMessage.UpdateSucessfully }));
                }

                else
                {
                    _context.TblTcContact.Add(new tblTcContact
                    {
                        MobileNo          = mdl.MobileNo,
                        AlternateMobileNo = mdl.AlternateMobileNo,
                        CreatedBy         = currentUsers.TcNid,
                        CreatedDt         = DateTime.Now,
                        Isdeleted         = false,
                        TcNid             = currentUsers.TcNid,
                    });
                    _context.SaveChanges();
                    return(RedirectToAction("Contact",
                                            new { _enmSaveStatus = enmSaveStatus.success, _enmMessage = enmMessage.SaveSucessfully }));
                }
            }

            return(View(mdl));
        }