Пример #1
0
        public async Task <HelperServiceScope> AddHelperServiceScopeAsync(HelperServiceScope helperServiceScope)
        {
            var result = await scopeContext.InsertAsync(helperServiceScope);

            return(result);
        }
Пример #2
0
        public async Task <IHttpActionResult> PostHelperService([FromBody] HelperServiceDTO helperServiceDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Helper helper = new Helper
            {
                UserId        = helperServiceDTO.UserId,
                Experience    = helperServiceDTO.ExperienceYears,
                MaxAgeGroup   = helperServiceDTO.MaxAge,
                MinAgeGroup   = helperServiceDTO.MinAge,
                Qualification = helperServiceDTO.Qualification,
                RowStatus     = "I",
                Status        = true,
                CreatedDate   = DateTime.UtcNow
            };

            try
            {
                var result = await services.AddHelperAsync(helper);

                var helperId = result.HelperId;

                HelperService helperService = null;
                foreach (var item in helperServiceDTO.Service)
                {
                    int LocationId = 0;
                    if (!String.IsNullOrEmpty(item.Latitude) && !String.IsNullOrEmpty(item.Longitude))
                    {
                        DbGeography geography = LocationPoint.CreatePoint(Convert.ToInt64(item.Latitude), Convert.ToInt64(item.Longitude));
                        Location1   location  = new Location1
                        {
                            LocationName      = item.LocationName,
                            LocationGeography = geography,
                            RowStatus         = "I",
                            CreatedDate       = DateTime.UtcNow
                        };

                        var locationResult = await utilityServices.AddLocationAsync(location);

                        LocationId = locationResult.LocationId;
                    }

                    helperService = new HelperService
                    {
                        HelperId      = helperId,
                        HourPrice     = item.Hour,
                        MaxDayPrice   = item.MaxDayPrice,
                        MaxHourPrice  = item.MaxPriceHour,
                        MaxMonthPrice = item.MaxMonthPrice,
                        MinDayPrice   = item.MinDayPrice,
                        MinHourPrice  = item.MinPriceHour,
                        MinMonthPrice = item.MinMonthPrice,
                        MonthlyPrice  = item.Month,
                        RowStatus     = "I",
                        ServiceId     = item.ServiceId,
                        Status        = true,
                        CreatedDate   = DateTime.UtcNow
                    };

                    var serviceResult = await services.AddHelperServiceAsync(helperService);

                    int ServiceId = serviceResult.HelperServiceId;

                    if (item.Scopes.Count != 0)
                    {
                        HelperServiceScope serviceScope = null;
                        foreach (var scope in item.Scopes)
                        {
                            serviceScope = new HelperServiceScope
                            {
                                HelperServiceId = ServiceId,
                                HelperScopeId   = scope.ScopeId,
                                RowStatus       = "I",
                                CreatedDate     = DateTime.UtcNow
                            };
                            var scopResult = await services.AddHelperServiceScopeAsync(serviceScope);
                        }
                    }
                }
            }
            catch (DbUpdateException)
            {
                if (HelperServiceExists(helper.HelperId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(Ok());
        }
Пример #3
0
        public HelperServiceScope AddHelperServiceScope(HelperServiceScope helperServiceScope)
        {
            var result = scopeContext.Insert(helperServiceScope);

            return(result);
        }