コード例 #1
0
        public override Models.IEntity Create(DbDataReader rdr)
        {
            var p = new Models.Plan();

            p.Id                 = (int)rdr["Id"];
            p.TyviId             = (int?)this.GetValueOrNull(rdr, "TyviId");
            p.Name               = rdr["Name"].ToString();
            p.MunicipalityId     = (int)rdr["MunicipalityId"];
            p.MunicipalityPlanId = rdr["MunicipalityPlanId"].ToString();
            p.GeneratedPlanId    = rdr["GeneratedPlanId"].ToString();

            p.ApprovalDate = (DateTime?)this.GetValueOrNull(rdr, "ApprovalDate");
            p.ProposalDate = (DateTime?)this.GetValueOrNull(rdr, "ProposalDate");
            p.InitialDate  = (DateTime?)this.GetValueOrNull(rdr, "InitialDate");
            p.FillDate     = (DateTime?)this.GetValueOrNull(rdr, "FillDate");
            p.Duration     = (decimal?)this.GetValueOrNull(rdr, "Duration");

            p.MunicipalityName          = rdr["MunicipalityName"].ToString();
            p.DecisionMaker             = rdr["DecisionMaker"].ToString();
            p.DecisionNumber            = rdr["DecisionNumber"].ToString();
            p.PlanArea                  = (decimal?)this.GetValueOrNull(rdr, "PlanArea");
            p.UndergroundArea           = (decimal?)this.GetValueOrNull(rdr, "UndergroundArea");
            p.PlanAreaNew               = (decimal?)this.GetValueOrNull(rdr, "PlanAreaNew");
            p.PlanAreaChange            = (decimal?)this.GetValueOrNull(rdr, "PlanAreaChange");
            p.CoastlineLength           = (decimal?)this.GetValueOrNull(rdr, "CoastlineLength");
            p.BuildingCountOwn          = (int?)this.GetValueOrNull(rdr, "BuildingCountOwn");
            p.BuildingCountOther        = (int?)this.GetValueOrNull(rdr, "BuildingCountOther");
            p.BuildingCountOwnHoliday   = (int?)this.GetValueOrNull(rdr, "BuildingCountOwnHoliday");
            p.BuildingCountOtherHoliday = (int?)this.GetValueOrNull(rdr, "BuildingCountOtherHoliday");

            return(p);
        }
コード例 #2
0
        public async Task <IActionResult> Post([FromBody] Models.Plan plan)
        {
            if (plan == null)
            {
                //_logger.LogInformation($"User is empty when accessing to UserController/Post(UserDto plan).");
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var planEntity = _mapper.Map <Entities.Plan>(plan);
            await _planRepository.AddAsync(planEntity);

            if (!await _planRepository.SaveAsync())
            {
                // _logger.LogError($"Add User is not valid. Error in SaveAsync(). When accessing to UserController/Post");
                return(StatusCode(500, "A problem happend while handling your request."));
            }

            //TODO: Implement Realistic Implementation
            return(Created("", null));
        }
コード例 #3
0
        // GET: Planes/Delete/5
        public ActionResult Eliminar(int id)
        {
            var plan  = this.planLogic.GetOne(id);
            var model = new Models.Plan(plan);

            return(View(model));
        }
コード例 #4
0
 public static TransitDirections GetTransitDirections(this Models.Plan plan)
 {
     return(new TransitDirections()
     {
         Routes = plan.Itineraries.Select(i => Format(i, plan)).ToArray()
     });
 }
コード例 #5
0
        // GET: Planes/Edit/5
        public ActionResult Editar(int id)
        {
            var plan  = this.planLogic.GetOne(id);
            var model = new Models.Plan(plan);

            model.Especialidades = this.EspecialidadesEdit(model.IDEspecialidad);
            return(View(model));
        }
コード例 #6
0
        // GET: Planes/Create
        public ActionResult Nuevo()
        {
            var model = new Models.Plan();

            model.Especialidades = this.Especialidades();

            return(View(model));
        }
コード例 #7
0
 public bool DeleteHRDPlan(Models.Plan hrdPlan)
 {
     if (hrdPlan == null)
     {
         return(false);
     }
     _unitOfWork.HrdPlanRepository.Delete(hrdPlan);
     _unitOfWork.Save();
     return(true);
 }
コード例 #8
0
ファイル: PlanService.cs プロジェクト: nathnael/cats
 public bool DeletePlan(Models.Plan plan)
 {
     if (plan == null)
     {
         return(false);
     }
     _unitOfWork.PlanRepository.Delete(plan);
     _unitOfWork.Save();
     return(true);
 }
コード例 #9
0
 public static Route Format(Models.Itinerary itinerary, Models.Plan plan)
 {
     return(new Route()
     {
         ArrivalTime = itinerary.EndTime,
         DepatureTime = itinerary.StartTime,
         Duration = (itinerary.EndTime - itinerary.StartTime).TotalSeconds,
         EndLocation = plan.To.Coordinate,
         StartLocation = plan.From.Coordinate,
         Steps = itinerary.Legs.Where(v => v.TransitLeg).Select(Format).ToArray(),
     });
 }
コード例 #10
0
ファイル: HomeController.cs プロジェクト: yong10/DojoActivity
        public IActionResult AddPlan(Models.Plan addPlan)
        {
            User current = GetUser();

            if (current == null)
            {
                return(Redirect("/login"));
            }
            if (ModelState.IsValid)
            {
                addPlan.UserId = current.UserId;
                _context.Plans.Add(addPlan);
                _context.SaveChanges();
                return(Redirect("/dashboard"));
            }
            return(View("NewPlan"));
        }
コード例 #11
0
        public DTOModels.Plan FromModelPlanToDTOModelPlan(Models.Plan modelPlan)
        {
            if (modelPlan == null)
            {
                throw new ArgumentNullException(nameof(modelPlan));
            }

            return(new DTOModels.Plan()
            {
                Amount = modelPlan.Amount,
                AmountToDisplay = modelPlan.Amount.ToString("N0"),
                MaxFactAmount = modelPlan.MaxAmountOfCost.ToString("N0"),
                CategoryId = modelPlan.CategoryId,
                CategoryName = modelPlan.Category?.CategoryName,
                SubCategoryName = modelPlan.Category?.SubCategoryName,
                Id = modelPlan.Id,
                Month = modelPlan.Month,
                Year = modelPlan.Year
            });
        }
コード例 #12
0
 public bool EditHRDPlan(Models.Plan hrdPlan)
 {
     _unitOfWork.HrdPlanRepository.Edit(hrdPlan);
     _unitOfWork.Save();
     return(true);
 }
コード例 #13
0
ファイル: PlanService.cs プロジェクト: nathnael/cats
 public bool AddPlan(Models.Plan plan)
 {
     _unitOfWork.PlanRepository.Add(plan);
     _unitOfWork.Save();
     return(true);
 }
コード例 #14
0
 public void SubscribeToPlan(string planId, int tenantId)
 {
     Models.Plan plan = _planRepository.GetAll().Where(p => p.PlanId == planId).FirstOrDefault();
     plan.TenantId = tenantId;
     _planRepository.Update(plan);
 }
コード例 #15
0
ファイル: PlanService.cs プロジェクト: nathnael/cats
 public bool EditPlan(Models.Plan plan)
 {
     _unitOfWork.PlanRepository.Edit(plan);
     _unitOfWork.Save();
     return(true);
 }
コード例 #16
0
 /// <summary>
 /// Adds specified plan to stripe if it doesn't exist
 /// </summary>
 private static async Task AddPlan(PlanService planService, StripeList <Stripe.Plan> plans, Models.Plan plan, string productId)
 {
     if (!plans.Any(x => x.Nickname.Equals(plan.Name)))
     {
         await planService.CreateAsync(new PlanCreateOptions
         {
             Nickname = plan.Name,
             Amount   = plan.PricePerUnit,
             Metadata = plan.Metadata,
             Product  = new PlanProductOptions()
             {
                 Id = productId
             },
             Interval = plan.Interval.ToString().ToLower(),
             Currency = plan.PlanCurrency.ToString().ToLower(),
         });
     }
 }
コード例 #17
0
        public int CreatePlan(PlanDto planDto)
        {
            var currency = new Currency()
            {
                value    = planDto.PaymentAmount,
                currency = planDto.PaymentCurrency
            };

            var shippingChargeModel = new ChargeModel()
            {
                type   = "SHIPPING",
                amount = new Currency()
                {
                    value    = "1",
                    currency = planDto.PaymentCurrency
                }
            };

            var paymentDefinition = new PaymentDefinition()
            {
                name               = planDto.PaymentName,
                type               = planDto.PaymentType,
                frequency          = planDto.PaymentFrequency,
                frequency_interval = planDto.PaymentFrequencyInterval,
                amount             = currency,
                cycles             = planDto.PaymentCycles,
                charge_models      = new List <ChargeModel>
                {
                    new ChargeModel()
                    {
                        type   = "TAX",
                        amount = new Currency {
                            value    = "1",
                            currency = planDto.PaymentCurrency
                        }
                    },
                    shippingChargeModel
                }
            };

            var plan = new PayPal.Api.Plan
            {
                name        = planDto.Name,
                description = planDto.Description,
                type        = "fixed",

                payment_definitions = new List <PaymentDefinition>
                {
                    paymentDefinition
                },

                merchant_preferences = new MerchantPreferences()
                {
                    setup_fee = new Currency()
                    {
                        value    = "0",
                        currency = planDto.PaymentCurrency
                    },
                    return_url                 = "https://localhost:5001/api/values",
                    cancel_url                 = "https://localhost:5001/api/houses",
                    auto_bill_amount           = "YES",
                    initial_fail_amount_action = "CONTINUE",
                    max_fail_attempts          = "0"
                }
            };

            var createdPlan = plan.Create(_apiContext);
            var state       = new
            {
                state = "ACTIVE"
            };
            var patchRequest = new PatchRequest()
            {
                new Patch()
                {
                    op    = "replace",
                    path  = "/",
                    value = state
                }
            };

            createdPlan.Update(_apiContext, patchRequest);

            //save plan in db
            var planToSave = new Models.Plan
            {
                Name    = createdPlan.name,
                PlanId  = createdPlan.id,
                OwnerId = planDto.OwnerId
            };

            var planInsert = _planRepository.Insert(planToSave);

            return(planInsert.Id);
        }