public async Task <IActionResult> Post([FromBody] AgentModel model)
        {
            try
            {
                model = await _agentService.Find(model.Id);

                if (model != null)
                {
                    await _agentService.Remove(model.Id);
                }

                model = await _agentService.Add(model);

                return(CreatedAtRoute(
                           "GetAgentById",
                           new { id = model.Id },
                           model));
            }
            catch (Exception ex)
            {
                HandleError(ex);

                return(StatusCode(500, model));
            }
        }
示例#2
0
        public IActionResult AddAgentByAgencyUUID(Guid agencyUUID, [FromBody] AgentCreate model)
        {
            var result = _agentService.Add(agencyUUID, model.ToDataModel());

            return(ProcessResult(result,
                                 a => Ok(new BaseResponse <Agent>(a.ToDTOModel()))
                                 ));
        }
        public ActionResult Create([Bind(Include = "id,Nom,Prenom,Email,CIN,sexe,DateNaissance,LieuNaissance,Nationalite,SecondeNationalite,Matricule,NbrEnfants")] Agent agent)
        {
            if (ModelState.IsValid)
            {
                _agentService.Add(agent);
                _agentService.Commit();


                //db.Agent.Add(agent);
                //db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(agent));
        }
示例#4
0
        public IActionResult AddAgent(Agent agent)
        {
            if (ModelState.IsValid)
            {
                var userId = _httpContextAccessor.HttpContext?.Session.GetString("adminId");

                Agent addedAgent = new Agent()
                {
                    CompanyName    = agent.CompanyName,
                    Username       = agent.Username,
                    AddedByAdminId = userId
                };

                _agentService.Add(addedAgent);
                return(View());
            }

            return(View());
        }
        public IActionResult Create(AgentViewModel model)
        {
            ReturnModel returnModel = new ReturnModel();

            if (!ModelState.IsValid)
            {
                returnModel.IsSuccess = false;
                returnModel.Message   = "Formu Eksiksiz Doldurunuz";
                return(Ok(returnModel));
            }

            var newAgent = new Agent
            {
                FirstName       = model.Agent.FirstName,
                LastName        = model.Agent.LastName,
                UserName        = model.Agent.UserName,
                CompanyName     = model.Agent.CompanyName,
                Role            = model.Agent.Role,
                Password        = model.Agent.Password,
                ConfirmPassword = model.Agent.ConfirmPassword,
                IsActive        = true,
                CreatedBy       = User.Identity.Name,
                CreatedDate     = DateTime.Now,
                UpdatedBy       = User.Identity.Name,
                UpdatedDate     = DateTime.Now
            };



            try
            {
                _agentService.Add(newAgent);
                returnModel.IsSuccess = true;
                returnModel.Message   = "Kayıt Başarılı";
            }
            catch (Exception ex)
            {
                returnModel.IsSuccess = false;
                returnModel.Message   = "Hata Oluştu" + ex.Message;
            }
            return(Ok(returnModel));
        }
示例#6
0
        public object SaveAgent(bool isEditMode, string evnt, [FromBody] Reginfo regInfo)
        {
            try
            {
                if (isEditMode != true)
                {
                    int fourDigitRandomNo = new Random().Next(1000, 9999);
                    try
                    {
                        if (string.IsNullOrEmpty(regInfo.Pmphone))
                        {
                            return(HttpStatusCode.BadRequest);
                        }
                        regInfo.CatId      = "A";
                        regInfo.PinStatus  = "N";
                        regInfo.AcTypeCode = 1;
                        regInfo.RegSource  = "P";
                        //regInfo.RegDate = regInfo.RegDate + DateTime.Now.TimeOfDay;
                        regInfo.RegDate   = System.DateTime.Now;
                        regInfo.EntryDate = System.DateTime.Now;
                        _service.Add(regInfo);
                        _kycService.InsertModelToAuditTrail(regInfo, regInfo.EntryBy, 3, 3, "Agent", regInfo.Mphone, "Save successfully");
                        return(HttpStatusCode.OK);
                    }
                    catch (Exception ex)
                    {
                        return(HttpStatusCode.BadRequest);
                    }
                }
                else
                {
                    if (evnt == "edit")
                    {
                        regInfo.UpdateDate = System.DateTime.Now;
                        Reginfo aReginfo  = _kycService.NullifyReginfoForKycUpdate(regInfo);
                        var     prevModel = _kycService.GetRegInfoByMphone(aReginfo.Mphone);
                        _service.UpdateRegInfo(aReginfo);
                        var currentModel = _kycService.GetRegInfoByMphone(aReginfo.Mphone);
                        _kycService.InsertUpdatedModelToAuditTrail(currentModel, prevModel, regInfo.UpdateBy, 3, 4, "Agent", regInfo.Mphone, "Update successfully");
                        return(HttpStatusCode.OK);
                    }

                    else
                    {
                        var checkStatus = _kycService.CheckPinStatus(regInfo.Mphone);
                        if (checkStatus.ToString() != "P")
                        {
                            if (string.IsNullOrEmpty(regInfo.AuthoBy))
                            {
                                return(HttpStatusCode.Unauthorized);
                            }
                            int fourDigitRandomNo = new Random().Next(1000, 9999);
                            regInfo.RegStatus = "P";
                            regInfo.AuthoDate = System.DateTime.Now;
                            var prevModel = _kycService.GetRegInfoByMphone(regInfo.Mphone);
                            _service.UpdateRegInfo(regInfo);
                            _dsrService.UpdatePinNo(regInfo.Mphone, fourDigitRandomNo.ToString());
                            var currentModel = _kycService.GetRegInfoByMphone(regInfo.Mphone);
                            _kycService.InsertUpdatedModelToAuditTrail(currentModel, prevModel, regInfo.AuthoBy, 3, 4, "Agent", regInfo.Mphone, "Register successfully");
                            MessageService service = new MessageService();
                            service.SendMessage(new MessageModel()
                            {
                                Mphone      = regInfo.Mphone,
                                MessageId   = "999",
                                MessageBody = "Congratulations! Your OK wallet has been opened successfully." + " Your Pin is "
                                              + fourDigitRandomNo.ToString() + ", please change PIN to activate your account, "
                            });

                            return(HttpStatusCode.OK);
                        }
                        else
                        {
                            return(HttpStatusCode.OK);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                errorLogService.InsertToErrorLog(ex, MethodBase.GetCurrentMethod().Name, Request.Headers["UserInfo"].ToString());
                return(HttpStatusCode.BadRequest);
            }
        }