コード例 #1
0
        public override Task <MedicationPlanReply> GetMedicationPlan(MedicationPlanRequest request, ServerCallContext context)
        {
            _logger.LogInformation($"Get today's medications for patient with ID " + request.PatientId);

            var medicationPlans = _medicationPlanService.GetMedicationPlanForPatient(request.PatientId);

            var today = DateTime.Today;

            var reply = new MedicationPlanReply();

            foreach (MedicationPlanModel medPlan in medicationPlans)
            {
                if (DateTime.Compare(medPlan.StartDate, today) <= 0 && DateTime.Compare(medPlan.EndDate, today) >= 0)
                {
                    foreach (MedicationPlanDetailsModel planDetails in medPlan.MedicationList)
                    {
                        string[] intakeIntervals = planDetails.IntakeInterval.Split(", ");
                        foreach (string interval in intakeIntervals)
                        {
                            string[] intervalHours = interval.Split("-");

                            var details = new PlanDetails {
                                MedicationId = planDetails.Medication.MedicationId, Name = planDetails.Medication.Name, IntakeIntervalStart = intervalHours[0], IntakeIntervalEnd = intervalHours[1]
                            };
                            reply.Medication.Add(details);
                        }
                    }
                }
            }

            return(Task.FromResult(reply));
        }
コード例 #2
0
        public List <PlanDetails> StartMyFreeMonth()
        {
            List <PlanDetails> lst = new List <PlanDetails>();
            DataSet            ds  = new DataSet();

            ds = _admindata.GetAllPlan("select");
            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    PlanDetails planDetails = new PlanDetails();
                    planDetails.ID           = Convert.ToInt32(row["ID"]);
                    planDetails.Title        = row["Title"].ToString();
                    planDetails.Description  = row["Description"].ToString();
                    planDetails.FreeInfo     = row["FreeInfo"].ToString();
                    planDetails.Cost         = Convert.ToDecimal(row["Cost"]);
                    planDetails.Validity     = Convert.ToInt32(row["Validity"]);
                    planDetails.Year         = Convert.ToInt32(row["Year"]);
                    planDetails.CreatedDate  = Convert.ToDateTime(row["CreatedDate"]);
                    planDetails.UpdateDate   = Convert.ToDateTime(row["UpdateDate"]);
                    planDetails.OrderDisplay = Convert.ToInt32(row["OrderDisplay"]);
                    planDetails.IsActive     = Convert.ToBoolean(row["IsActive"]);
                    planDetails.Group        = row["GroupOrder"].ToString();
                    lst.Add(planDetails);
                }
            }
            return(lst);
        }
コード例 #3
0
        public int Insert(PlanDetails pd)
        {
            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            string sqlStmt = "INSERT INTO PlanDetails (Name, Location1, Location2, Location3, Price, Duration, Description)" +
                             "VALUES (@paraName, @paraLocation1, @paraLocation2, @paraLocation3, @paraPrice, @paraDuration, @paraDesc)";

            int        result = 0;
            SqlCommand sqlCmd = new SqlCommand(sqlStmt, myConn);

            sqlCmd.Parameters.AddWithValue("@paraName", pd.Name);
            sqlCmd.Parameters.AddWithValue("@paraLocation1", pd.LocationFirst);
            sqlCmd.Parameters.AddWithValue("@paraLocation2", pd.LocationSecond);
            sqlCmd.Parameters.AddWithValue("@paraLocation3", pd.LocationThird);
            sqlCmd.Parameters.AddWithValue("@paraPrice", pd.Price);
            sqlCmd.Parameters.AddWithValue("@paraDuration", pd.Duration);
            sqlCmd.Parameters.AddWithValue("@paraDesc", pd.Description);

            myConn.Open();
            result = sqlCmd.ExecuteNonQuery();

            myConn.Close();

            return(result);
        }
コード例 #4
0
        public List <PlanDetails> RetrieveAll()
        {
            List <PlanDetails> list = new List <PlanDetails>();

            string        DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString;
            SqlConnection myConn    = new SqlConnection(DBConnect);

            string sqlStmt = "SELECT * FROM PlanDetails";

            SqlCommand sqlCmd = new SqlCommand(sqlStmt, myConn);

            myConn.Open();

            SqlDataReader dr = sqlCmd.ExecuteReader();

            while (dr.Read())
            {
                PlanDetails plan = Read(dr);
                list.Add(plan);
            }

            myConn.Close();

            return(list);
        }
コード例 #5
0
        public async Task <int> AddPlanDetails(PlanDetails planDetails)
        {
            int result = 0;

            using (IDbConnection con = new SqlConnection(_config.GetConnectionString("DefaultConnection")))
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                DynamicParameters parameter = new DynamicParameters();
                parameter.Add("@PlanName", planDetails.PlanName);
                parameter.Add("@PlanType", planDetails.PlanType);
                parameter.Add("@IsInterest", planDetails.IsInterest);
                parameter.Add("@StartDate", planDetails.StartDate);
                parameter.Add("@WithdrawalDate", planDetails.WithdrawalDate);
                parameter.Add("@Target", planDetails.Target);
                parameter.Add("@AmountToSave", planDetails.AmountToSave);
                parameter.Add("@CardDetailsId", 1);
                parameter.Add("@UserId", 1);
                parameter.Add("@InterestRate", planDetails.InterestRate = (planDetails.IsInterest == 1) ? 10 : 0);
                parameter.Add("@WithdrawalInterval", planDetails.WithdrawalInterval);
                result = await con.QueryFirstAsync <int>("Hackathon_GroupD_AddPlan", parameter, commandType : CommandType.StoredProcedure);
            }

            return(result);
        }
コード例 #6
0
        public async Task <ResponseModel> AddPlan(PlanDetails planDetails)
        {
            ResponseModel response = new ResponseModel();

            try
            {
                var result = await _personalSavingsRepo.AddPlanDetails(planDetails);

                if (result > 0)
                {
                    response.ResponseCode    = "00";
                    response.ResponseMessage = "Successfully added a new plan";
                }
                else
                {
                    response.ResponseCode    = "99";
                    response.ResponseMessage = "An error occured while adding a new plan. please check your network";
                }
            }
            catch (Exception e)
            {
                response.ResponseCode    = "99";
                response.ResponseMessage = "An error occured while processing the request. check connection";
                _logger.LogError($"An Error occured while processing the request {e.Message}");
            }

            return(response);
        }
コード例 #7
0
        private void btnRunSingleAgentPlan_Click(object sender, EventArgs e)
        {
            // Active agent
            Constant activeAgent = (Constant)cbActiveAgents.SelectedItem;

            // Active goals
            List <Predicate> activeGoals = new List <Predicate>();

            for (int i = 0; i < clbActiveGoals.Items.Count; i++)
            {
                if (clbActiveGoals.GetItemChecked(i))
                {
                    activeGoals.Add((Predicate)clbActiveGoals.Items[i]);
                }
            }

            // Required Actions to be preformed
            List <Action> reqCollabActions = new List <Action>();

            for (int i = 0; i < clbActiveJointActions.Items.Count; i++)
            {
                if (clbActiveJointActions.GetItemChecked(i))
                {
                    reqCollabActions.Add((Action)clbActiveJointActions.Items[i]);
                }
            }

            // Active Prev achieved goals
            List <KeyValuePair <Predicate, int> > prevAchievedGoals = new List <KeyValuePair <Predicate, int> >();

            for (int i = 0; i < clbPrevGoalTime.Items.Count; i++)
            {
                if (clbPrevGoalTime.GetItemChecked(i))
                {
                    prevAchievedGoals.Add((KeyValuePair <Predicate, int>)clbPrevGoalTime.Items[i]);
                }
            }

            Domain  reducedDomain  = Parser.ParseDomain(m_DomainPath, m_AgentCallsign);
            Problem reducedProblem = Parser.ParseProblem(m_ProblemPath, reducedDomain);

            string sPath = Directory.GetParent(reducedDomain.Path).FullName + "\\";

            SingleAgentSDRPlanner m_saSDRPlanner = new SingleAgentSDRPlanner(reducedDomain,
                                                                             reducedProblem,
                                                                             (SDRPlanner.Planners)cbPlanner.SelectedItem);

            PlanResult planResult = m_saSDRPlanner.Plan(activeAgent, activeGoals, prevAchievedGoals, reqCollabActions);

            ConditionalPlanTreeNode root = planResult.Plan;
            PlanDetails             pd   = root.ScanDetails(reducedDomain, reducedProblem);

            pd.PlanningTime = planResult.PlanningTime;
            pd.Valid        = planResult.Valid;
            pd.ActiveAgent  = activeAgent;
            AddResult(pd);
        }
コード例 #8
0
        public ucExecuteResults(PlanDetails pd) : this()
        {
            PlanDetails = pd;

            rtxtPlan.Text        = PlanTreePrinter.Print(pd.Plan);;
            lblAvgDepth.Text     = pd.LeafsDepth.Average().ToString();
            lblMakespan.Text     = pd.MakeSpan.ToString();
            lblValid.Text        = pd.Valid.ToString();
            lblPlanningTime.Text = (pd.PlanningTime.TotalMilliseconds / (double)1000).ToString(".##") + "s";


            UpdateCollabActions(pd.JointActionsTimes);
            UpdateGoalAchievementsTime(pd.GoalsTiming);
        }
コード例 #9
0
        private void AddResult(PlanDetails pd)
        {
            ucExecuteResults er = new ucExecuteResults(pd);

            er.SelectedGoalAchievementTime += Er_SelectedGoalAchievementTime;
            er.SelectedJointActionReq      += Er_SelectedJointActionReq;
            er.CloseTab   += Er_CloseTab;
            er.AddtoFinal += Er_AddtoFinal;
            TabPage tp = new TabPage();

            tp.Text = "agent " + pd.ActiveAgent.ToString();
            tp.Controls.Add(er);
            tcResults.TabPages.Add(tp);
        }
コード例 #10
0
        private void AddResult(Constant agent, ConditionalPlanTreeNode plan, PlanDetails pd, TimeSpan planningTime, Boolean valid)
        {
            string           planAsText = PlanTreePrinter.Print(plan);
            ucExecuteResults er         = new ucExecuteResults(agent, planAsText, pd, planningTime, valid);

            er.SelectedGoalAchievementTime += Er_SelectedGoalAchievementTime;
            er.CloseTab   += Er_CloseTab;
            er.AddtoFinal += Er_AddtoFinal;
            TabPage tp = new TabPage();

            tp.Text = "agent " + agent.ToString();
            tp.Controls.Add(er);
            tcResults.TabPages.Add(tp);
        }
コード例 #11
0
ファイル: StaffStats.aspx.cs プロジェクト: 182441S/eadProject
        protected void TotalPlanSales()
        {
            BookingDetails bd = new BookingDetails();
            PlanDetails    pd = new PlanDetails();

            List <string> planNames = pd.GetPlanNames();
            List <int>    planSales = bd.GetPlanSales(planNames);

            Series series = Chart1.Series["SeriesStats"];

            for (int i = 0; i < planNames.Count; i++)
            {
                series.Points.AddXY(planNames[i], planSales[i]);
            }
        }
コード例 #12
0
ファイル: PlanHelper.cs プロジェクト: Zorzin/HomeWallet_API
        public PlanDetails GetPlanDetails(Plan plan)
        {
            var planDetails = new PlanDetails()
            {
                AlreadySpent        = GetAlreadySpent(plan.UserID, plan.StartDate, plan.EndDate),
                AlreadySpentPercent = GetPercentageSpent(plan.UserID, plan.StartDate, plan.EndDate, plan.Amount),
                Amount      = plan.Amount,
                AverageLeft = GetAveragePerDay(plan.UserID, plan.StartDate, plan.EndDate, plan.Amount),
                DaysLeft    = GetDaysLeft(plan.EndDate),
                EndDate     = plan.EndDate,
                ID          = plan.ID,
                MoneyLeft   = GetMoneyLeft(plan.UserID, plan.StartDate, plan.EndDate, plan.Amount),
                StartDate   = plan.StartDate,
                DaysBehind  = GetDaysBehind(plan.StartDate, plan.EndDate)
            };


            return(planDetails);
        }
コード例 #13
0
 public void UpdateModel(GameObject original)
 {
     try
     {
         PlanDetails detailsToUpdate =
             PlanManager.instance.currentPlan.details.FirstOrDefault(detail => detail.item_name == gameObject.name);
         detailsToUpdate.position_x = original.transform.position.x;
         detailsToUpdate.position_y = original.transform.position.y;
         detailsToUpdate.rotation_z = original.transform.rotation.z;
         detailsToUpdate.sDelta_x   = original.GetComponent <RectTransform>().sizeDelta.x;
         detailsToUpdate.sDelta_y   = original.GetComponent <RectTransform>().sizeDelta.y;
         //detailsToUpdate.img_width = 300;
         //detailsToUpdate.img_width = 300;
     }
     catch (System.Exception ex)
     {
         Debug.Log(ex.Message);
     }
 }
コード例 #14
0
        private async void Search()
        {
            var _list  = Details;
            var result = _list.FirstOrDefault(a => a.BarCode == BCode);

            if (result != null)
            {
                Page x = new PlanDetails(result.IdCountPlan, result.ProductCode, User, PlanDescription, BCode,
                                         result.ProductDescription);

                await Xamarin.Forms.Application.Current.MainPage.Navigation.PushAsync(new PlanDetails(result.IdCountPlan, result.ProductCode, User, PlanDescription, BCode, result.ProductDescription));

                //await Xamarin.Forms.Application.Current.MainPage.Navigation.PopAsync(await PlanDetails(result.IdCountPlan, result.ProductCode, User, PlanDescription, BCode, result.ProductDescription));
                //await Xamarin.Forms.Application.Current.MainPage.Navigation.PopAsync(x);
            }
            else
            {
                MessageResult = "Producto no Registrado";
            }
        }
コード例 #15
0
        public ActionResult StartMyFreeMonth()
        {
            List <PlanDetails> lst = new List <PlanDetails>();
            DataSet            ds  = new DataSet();

            ds = _admindata.GetAllPlan("select");
            if (ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    PlanDetails planDetails = new PlanDetails();
                    planDetails.ID           = Convert.ToInt32(row["ID"]);
                    planDetails.Title        = row["Title"].ToString();
                    planDetails.Description  = row["Description"].ToString();
                    planDetails.FreeInfo     = row["FreeInfo"].ToString();
                    planDetails.Cost         = Convert.ToDecimal(row["Cost"]);
                    planDetails.Validity     = Convert.ToInt32(row["Validity"]);
                    planDetails.Year         = Convert.ToInt32(row["Year"]);
                    planDetails.CreatedDate  = Convert.ToDateTime(row["CreatedDate"]);
                    planDetails.UpdateDate   = Convert.ToDateTime(row["UpdateDate"]);
                    planDetails.OrderDisplay = Convert.ToInt32(row["OrderDisplay"]);
                    planDetails.IsActive     = Convert.ToBoolean(row["IsActive"]);
                    planDetails.Group        = row["GroupOrder"].ToString();
                    lst.Add(planDetails);
                }
            }
            if (Session["BPType"] != null)
            {
                lst = lst.Where(x => x.Group.ToLower().Trim() == Session["BPType"].ToString().ToLower().Trim() || x.Cost == 0).ToList();
            }

            ////-Nitin Check for expiry of account
            if (TempData["expiredate"] != null)
            {
                ViewBag.ExpireDate = Convert.ToDateTime(TempData["expiredate"]).ToShortDateString();
                TempData.Keep();
            }

            return(View(lst));
        }
コード例 #16
0
        private static PlanDetails Read(SqlDataReader dr)
        {
            string name           = dr["Name"].ToString();
            string locationFirst  = dr["Location1"].ToString();
            string locationSecond = dr["Location2"].ToString();
            string locationThird  = dr["Location3"].ToString();
            int    price          = int.Parse(dr["Price"].ToString());
            int    duration       = int.Parse(dr["Duration"].ToString());
            string description    = dr["Description"].ToString();

            PlanDetails plan = new PlanDetails
            {
                Name           = name,
                LocationFirst  = locationFirst,
                LocationSecond = locationSecond,
                LocationThird  = locationThird,
                Price          = price,
                Duration       = duration,
                Description    = description
            };

            return(plan);
        }
コード例 #17
0
        public async Task <PlanDetails> CheckDateAgainstWithdrawalDate(string planName)
        {
            //int response = 0;
            PlanDetails plan = new PlanDetails();

            using (IDbConnection con = new SqlConnection(_config.GetConnectionString("DefaultConnection")))
            {
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                DynamicParameters parameter = new DynamicParameters();
                parameter.Add("@PlanName", planName);
                var result = await con.QueryFirstAsync <PlanDetails>("Hackathon_GroupD_CheckWithdrawalDate", parameter, commandType : CommandType.StoredProcedure);

                if (!String.IsNullOrEmpty(result.WithdrawalDate))
                {
                    plan.WithdrawalDate = result.WithdrawalDate;
                    plan.PlanBalance    = result.PlanBalance;
                }
            }

            return(plan);
        }
コード例 #18
0
        public void CreateAndWithdrawApprovalRequestTest()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                using (var client = context.GetServiceClient <MarketplaceRPServiceClient>())
                {
                    SetUp(client);

                    //create approval request
                    PlanDetails planDetails = new PlanDetails
                    {
                        PlanId           = planId,
                        Justification    = "because ...",
                        SubscriptionId   = testSubscription,
                        SubscriptionName = TestSubscriptionName
                    };

                    RequestApprovalResource requestApprovalResource = new RequestApprovalResource
                    {
                        PublisherId  = "data3-limited-1019419",
                        PlansDetails = new List <PlanDetails>()
                        {
                            planDetails
                        }
                    };

                    try
                    {
                        var approvalRequest = client.PrivateStore.CreateApprovalRequest(PrivateStoreId, requestApprovalId, requestApprovalResource);
                    }
                    catch (Exception ex)
                    {
                        if (!ex.Message.Contains("BadRequest"))
                        {
                            throw;
                        }
                    }

                    // Assert notification arrived
                    var notificationState = client.PrivateStore.QueryNotificationsState(PrivateStoreId);
                    Assert.Contains(notificationState.ApprovalRequests, x => x.OfferId == requestApprovalId);

                    var adminRequestApproval = client.PrivateStore.GetAdminRequestApproval(publisherId, PrivateStoreId, requestApprovalId);
                    Assert.Equal("Pending", adminRequestApproval.AdminAction);

                    RequestDetails requestDetails = new RequestDetails
                    {
                        PublisherId = publisherId,
                        PlanIds     = new List <string> {
                            planId, managedAzurePlanId, managedAzureOptimiser
                        },
                        SubscriptionId = testSubscription
                    };
                    QueryRequestApprovalProperties queryRequestApprovalProperties = new QueryRequestApprovalProperties
                    {
                        Properties = requestDetails
                    };
                    var requestApproval = client.PrivateStore.QueryRequestApprovalMethod(PrivateStoreId, requestApprovalId, queryRequestApprovalProperties);
                    Assert.Equal("Pending", requestApproval.PlansDetails[planId].Status);

                    // Withdraw request
                    WithdrawProperties withdrawProperties = new WithdrawProperties
                    {
                        PublisherId = publisherId,
                        PlanId      = planId
                    };
                    client.PrivateStore.WithdrawPlan(PrivateStoreId, requestApprovalId, withdrawProperties);

                    notificationState = client.PrivateStore.QueryNotificationsState(PrivateStoreId);
                    Assert.DoesNotContain(notificationState.ApprovalRequests, x => x.OfferId == requestApprovalId);

                    CleanUp(client);
                }
            }
        }
コード例 #19
0
        public void ApproveByAdminNotificationTest()
        {
            using (var context = MockContext.Start(this.GetType()))
            {
                using (var client = context.GetServiceClient <MarketplaceRPServiceClient>())
                {
                    SetUp(client);
                    //create approval request
                    PlanDetails planDetails = new PlanDetails
                    {
                        PlanId           = planId,
                        Justification    = "because ...",
                        SubscriptionId   = testSubscription,
                        SubscriptionName = TestSubscriptionName
                    };
                    RequestApprovalResource requestApprovalResource = new RequestApprovalResource
                    {
                        PublisherId  = "data3-limited-1019419",
                        PlansDetails = new List <PlanDetails>()
                        {
                            planDetails
                        }
                    };

                    try
                    {
                        var approvalRequest = client.PrivateStore.CreateApprovalRequest(PrivateStoreId, requestApprovalId, requestApprovalResource);
                    }
                    catch (Exception ex)
                    {
                        if (!ex.Message.Contains("BadRequest"))
                        {
                            throw;
                        }
                    }
                    var notificationState = client.PrivateStore.QueryNotificationsState(PrivateStoreId);
                    Assert.Contains(notificationState.ApprovalRequests, x => x.OfferId == requestApprovalId);

                    // Approve request by admin
                    AdminRequestApprovalsResource adminRequestApprovalsResource = new AdminRequestApprovalsResource
                    {
                        PublisherId   = publisherId,
                        AdminAction   = "Approved",
                        ApprovedPlans = new List <string>()
                        {
                            planId
                        },
                        Comment       = "I'm ok with that",
                        CollectionIds = new List <string>()
                        {
                            collectionId
                        }
                    };
                    client.PrivateStore.UpdateAdminRequestApproval(PrivateStoreId, requestApprovalId, adminRequestApprovalsResource);

                    var collectionOffers = client.PrivateStoreCollectionOffer.List(PrivateStoreId, collectionId);
                    Assert.Contains(collectionOffers, x => x.UniqueOfferId == requestApprovalId);

                    notificationState = client.PrivateStore.QueryNotificationsState(PrivateStoreId);
                    Assert.DoesNotContain(notificationState.ApprovalRequests, x => x.OfferId == requestApprovalId);

                    CleanUp(client);
                }
            }
        }
コード例 #20
0
        private Payment CreatePayment(APIContext apiContext, string redirectUrl, string planId, string guid, string token)
        {
            DataLogger.Write("PaymentWithPaypal-CreatePayment", "apiContext");


            PlanDetails planDetails = new PlanDetails();

            planDetails = _admindata.GetPlanByPlanId(planId);

            //create itemlist and add item objects to it
            var itemList = new ItemList()
            {
                items = new List <Item>()
            };

            //Adding Item Details like name, currency, price etc
            itemList.items.Add(new Item()
            {
                name     = planDetails.Title,
                currency = "USD",
                price    = Convert.ToString(planDetails.Cost),
                quantity = "1",
                sku      = "sku"
            });


            var payer = new Payer()
            {
                payment_method = "paypal"
            };
            //var payer = new Payer() {  payment_method = "credit_card" };

            // Configure Redirect Urls here with RedirectUrls object
            var redirUrls = new RedirectUrls()
            {
                //Request.Url.Scheme + "://" + Request.Url.Authority +"/Payment/PaymentWithPayPal?";
                cancel_url = Request.Url.Scheme + "://" + Request.Url.Authority + "/Payment/PaymentCancel?planid=" + planId + "&usertoken=" + token + "&guid=" + guid, //redirectUrl + "&Cancel=true",
                return_url = Request.Url.Scheme + "://" + Request.Url.Authority + "/Payment/PaymentSucess?planid=" + planId + "&usertoken=" + token + "&guid=" + guid
            };

            // Adding Tax, shipping and Subtotal details
            var details = new Details()
            {
                tax      = "0",
                shipping = "0",
                subtotal = Convert.ToString(planDetails.Cost)
            };

            //Final amount with details
            var amount = new Amount()
            {
                currency = "USD",
                total    = Convert.ToString(planDetails.Cost), // Total must be equal to sum of tax, shipping and subtotal.
                details  = details
            };

            var transactionList = new List <Transaction>();

            // Adding description about the transaction
            transactionList.Add(new Transaction()
            {
                description    = planDetails.Description,
                invoice_number = Convert.ToString((new Random()).Next(100000)), //"your invoice number", //Generate an Invoice No
                amount         = amount,
                item_list      = itemList
            });


            this.payment = new Payment()
            {
                intent        = "sale",
                payer         = payer,
                transactions  = transactionList,
                redirect_urls = redirUrls
            };

            // Create a payment using a APIContext
            return(this.payment.Create(apiContext));
        }
コード例 #21
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            bool error = false;

            LabelLocationError.Visible = false;
            LabelPriceError.Visible    = false;
            LabelDurationError.Visible = false;
            LabelDescError.Visible     = false;

            if (DropDownListLocFirst.SelectedValue == "-1" ||
                DropDownListLocSecond.SelectedValue == "-1" ||
                DropDownListLocThird.SelectedValue == "-1")
            {
                error = true;

                LabelLocationError.Text    = "Location not selected!";
                LabelLocationError.Visible = true;
            }
            else if (DropDownListLocFirst.SelectedValue == DropDownListLocSecond.SelectedValue ||
                     DropDownListLocFirst.SelectedValue == DropDownListLocThird.SelectedValue ||
                     DropDownListLocSecond.SelectedValue == DropDownListLocThird.SelectedValue)
            {
                error = true;

                LabelLocationError.Text    = "Locations are the same!";
                LabelLocationError.Visible = true;
            }

            if (TextBoxPrice.Text == "")
            {
                error = true;

                LabelPriceError.Text    = "Price is required!";
                LabelPriceError.Visible = true;
            }
            else
            {
                try
                {
                    int i = int.Parse(TextBoxPrice.Text);

                    if (i == 0)
                    {
                        error = true;

                        LabelPriceError.Text    = "Price cannot be 0!";
                        LabelPriceError.Visible = true;
                    }
                }
                catch
                {
                    error = true;

                    LabelPriceError.Text    = "Price must be a number!";
                    LabelPriceError.Visible = true;
                }
            }

            if (TextBoxDuration.Text == "")
            {
                error = true;

                LabelDurationError.Text    = "Duration is required!";
                LabelDurationError.Visible = true;
            }
            else
            {
                try
                {
                    int i = int.Parse(TextBoxDuration.Text);

                    if (i == 0)
                    {
                        error = true;

                        LabelDurationError.Text    = "Duration cannot be 0!";
                        LabelDurationError.Visible = true;
                    }
                }
                catch
                {
                    error = true;

                    LabelDurationError.Text    = "Duration must be a number!";
                    LabelDurationError.Visible = true;
                }
            }

            if (TextBoxDescription.Text == "")
            {
                error = true;

                LabelDescError.Text    = "Description is required!";
                LabelDescError.Visible = true;
            }

            if (!error)
            {
                string name           = LabelPlanName.Text.ToString();
                string locationFirst  = DropDownListLocFirst.SelectedValue;
                string locationSecond = DropDownListLocSecond.SelectedValue;
                string locationThird  = DropDownListLocThird.SelectedValue;
                int    price          = int.Parse(TextBoxPrice.Text);
                int    duration       = int.Parse(TextBoxDuration.Text);
                string description    = TextBoxDescription.Text.ToString();

                PlanDetails pd     = new PlanDetails();
                int         result = pd.UpdatePlanByName(name, locationFirst, locationSecond, locationThird, price, duration, description);

                if (result == 1)
                {
                    Response.Redirect("StaffPlan.aspx");
                }
            }
        }
コード例 #22
0
 public async Task <IActionResult> AddPlan([FromBody] PlanDetails planDetails)
 {
     return(Ok(await _personalSavings.AddPlan(planDetails)));
 }