Exemple #1
0
        public async Task <JsonResult> SaveUpdate(PrankCallFromPhoneNumberAddEditModel model)
        {
            string token          = string.Empty;
            var    claimsIdentity = (ClaimsIdentity)HttpContext.User.Identity;
            var    userTokenClaim = claimsIdentity.Claims.SingleOrDefault(c => c.Type == "Token");

            if (userTokenClaim != null)
            {
                token = userTokenClaim.Value;
            }
            var    data        = new ResponseModel();
            var    objResponse = new SaveResponse();
            string viewFromCurrentController = string.Empty;

            if (ModelState.IsValid)
            {
                try
                {
                    var FromPhNoModel = new PrankCallFromPhoneNumberModel()
                    {
                        PrankCallFromId = model.PrankCallFromId,
                        Country         = model.Country,
                        CountryCode     = model.CountryCode,
                        PhoneNumber     = model.PhoneNumber,
                        IsActive        = model.IsActive
                    };
                    if (model.PrankCallFromId > 0)
                    {
                        data = await ApiClientFactory.Instance.UpdatePrankCallFromPhoneNo(FromPhNoModel);
                    }
                    else
                    {
                        data = await ApiClientFactory.Instance.SavePrankCallFromPhoneNo(FromPhNoModel);
                    }
                    objResponse.StatusCode = Convert.ToInt32(data.StatusCode);

                    if (Convert.ToInt32(data.StatusCode) == 200)
                    {
                        objResponse.Message = model.PrankCallFromId > 0 ? "Record updated successfully" : "Record saved successfully";
                        await TrackingInfo.TrackInfo(token, EmployeeId, ControllerContext.ActionDescriptor.ControllerName, model.PhoneNumber,
                                                     model.PrankCallFromId, model.PrankCallFromId > 0? "Update" : "Save");
                    }
                    else
                    {
                        objResponse.Message = model.PrankCallFromId > 0 ? "Record not updated successfully" : "Record not saved successfully";
                    }
                    return(new JsonResult(new
                    {
                        objResponse
                    }));
                }
                catch (Exception ex)
                {
                    string exep = ex.ToString();
                }
            }
            return(new JsonResult(new List <string>()));
        }
Exemple #2
0
        public async Task <IActionResult> PartialAddEditCallFromNumber(int fromId)
        {
            var model = new PrankCallFromPhoneNumberAddEditModel();


            if (fromId > 0)
            {
                try
                {
                    string token          = string.Empty;
                    var    claimsIdentity = (ClaimsIdentity)HttpContext.User.Identity;
                    var    userTokenClaim = claimsIdentity.Claims.SingleOrDefault(c => c.Type == "Token");
                    if (userTokenClaim != null)
                    {
                        token = userTokenClaim.Value;
                    }
                    var result = await ApiClientFactory.Instance.GetPrankCallFromPhoneNoLst(token, fromId, 0, 1000000, string.Empty, string.Empty, string.Empty);;
                    if (result != null & result.Count > 0)
                    {
                        foreach (var item in result)
                        {
                            model.PrankCallFromId = item.PrankCallFromId;
                            model.Country         = item.Country;
                            model.CountryCode     = item.CountryCode;
                            model.PhoneNumber     = item.PhoneNumber;
                            model.IsActive        = item.IsActive;
                        }
                    }
                }
                catch (Exception e)
                {
                }
            }
            string viewFromCurrentController = await this.RenderViewToStringAsync("PartialAddEditCallFromNumber", model);

            return(Json(new { html = viewFromCurrentController }));
        }