Exemple #1
0
        public ActionResult Create()
        {
            SetSessionVariables();
            ViewBag.ListOfMembershipDurationTypes = Common.GetMembershipDurationTypes();
            MembershipPlanViewModel model = new MembershipPlanViewModel();

            return(View(model));
        }
Exemple #2
0
        public ActionResult Create(MembershipPlanViewModel model)
        {
            SetSessionVariables();

            if (model.MembershipDurationType == "Select Plan")
            {
                return(RedirectToAction("Index"));
            }

            model.clientMemPlan.ClientID               = GetSessionObject().ClientID;
            model.clientMemPlan.CreatedBy              = GetSessionObject().UserID;
            model.clientMemPlan.CreatedDateTime        = DateTime.Now;
            model.clientMemPlan.MembershipDurationType = model.MembershipDurationType;
            model.clientMemPlan.IsActive               = model.IsActive;
            model.clientMemPlan.IsRecommented          = model.IsRecommented;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Common.Instance.ApiClientControllerName);

                //HTTP POST
                var postTask = client.PostAsJsonAsync <ClientMembershipPlan>(Common.Instance.ApiClientAddEditClientMembershipPlan, model.clientMemPlan);
                postTask.Wait();

                var result = postTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var rs = result.Content.ReadAsAsync <ClientMembershipPlan>().Result;

                    ClientMembershipPlanHistory history = new ClientMembershipPlanHistory();
                    history.ClientMembershipPlanID = rs.ClientMembershipPlanID;
                    history.ClientID               = rs.ClientID;
                    history.MembershipName         = rs.MembershipName;
                    history.MembershipDuration     = rs.MembershipDuration;
                    history.MembershipDurationType = rs.MembershipDurationType;
                    history.Price           = rs.Price;
                    history.CreatedBy       = rs.CreatedBy;
                    history.CreatedDateTime = rs.CreatedDateTime;

                    postTask = client.PostAsJsonAsync <ClientMembershipPlanHistory>(Common.Instance.ApiClientAddClientMembershipPlanHistory, history);
                    postTask.Wait();
                    result = postTask.Result;
                    if (result.IsSuccessStatusCode)
                    {
                        var rs1 = result.Content.ReadAsAsync <bool>().Result;
                    }
                }
            }

            return(RedirectToAction("Index"));
        }
Exemple #3
0
        public ActionResult Display(int ClientMembershipPlanID)
        {
            SetSessionVariables();
            ViewBag.ListOfMembershipDurationTypes = Common.GetMembershipDurationTypes();
            MembershipPlanViewModel model = new MembershipPlanViewModel();

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri(Common.Instance.ApiClientControllerName);
                //HTTP GET
                var responseTask = client.GetAsync(Common.Instance.ApiClientGetClientMembershipPlanDetails + "/" + ClientMembershipPlanID.ToString());
                responseTask.Wait();

                var result = responseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var readTask = result.Content.ReadAsAsync <ClientMembershipPlan>();
                    readTask.Wait();

                    model.clientMemPlan          = readTask.Result;
                    model.MembershipDurationType = model.clientMemPlan.MembershipDurationType;
                    model.IsActive      = model.clientMemPlan.IsActive.Value;
                    model.IsRecommented = model.clientMemPlan.IsRecommented.Value;
                }
                else //web api sent error response
                {
                    //log response status here..



                    ModelState.AddModelError(string.Empty, "Server error. Please contact administrator.");
                }
            }

            return(View(model));
        }