Beispiel #1
0
        public async Task <IActionResult> AddStatus([FromBody] Status model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var statusId = await statusRepository.AddStatus(model);

                    if (statusId > 0)
                    {
                        return(Ok(statusId));
                    }
                    else
                    {
                        return(NotFound());
                    }
                }
                catch (Exception)
                {
                    return(BadRequest());
                }
            }

            return(BadRequest());
        }
Beispiel #2
0
 public async Task <ActionResult> AddProjectMilestone(Status model)
 {
     if (ModelState.IsValid)
     {
         return(Ok(await _repository.AddStatus(model)));
     }
     return(BadRequest());
 }
        public StatusResult AddStatus(StatusCreateViewModel model)
        {
            var result = _statusRepository.AddStatus(new ProductStatus {
                Name = model.Name
            });

            return(result ? StatusResult.Success : StatusResult.Failure);
        }
Beispiel #4
0
        public bool AddStatus(Status status)
        {
            logger.LogInformation("Statuses Business Logic - AddStatus");

            statusRepository.AddStatus(status);

            return(true);
        }
Beispiel #5
0
        public void InitializeGoogleLocations()
        {
            // Getting the place_id list and finding the details about each restaurant
            foreach (var placesId in _placesService.GetPlacesList())
            {
                // Getting the details of the information with the place_id
                DetailResult result = _placesService.GetDetailResult(placesId);

                // Creating new restaurant object with the information from Places API
                Restaurant newRestaurant = new Restaurant
                {
                    Name          = result.Name,
                    Phone         = result.FormattedPhoneNumber,
                    Address1      = result.FormattedAddress,
                    City          = result.FormattedAddress.Split(',')[1],
                    State         = result.FormattedAddress.Split(',')[2].Split(' ')[1],
                    ZipCode       = result.FormattedAddress.Split(',')[2].Split(' ')[2],
                    DateUpdated   = DateTime.Now,
                    GooglePlaceId = result.PlaceId
                };

                // Adding new restaurant
                _restaurantRepository.AddRestaurant(newRestaurant);

                // Creating a location object with the result
                Location newLocation = new Location
                {
                    Latitude     = result.Geometry.Location.Lat,
                    Longitude    = result.Geometry.Location.Lng,
                    RestaurantId = newRestaurant.RestaurantId
                };

                // Adding new location for the restaurant
                _locationRepository.AddLocation(newLocation);

                // Initializing status of the restaurant
                Status newStatus = new Status
                {
                    RestaurantId = newRestaurant.RestaurantId,
                    DriveThru    = 0,
                    InStore      = 0
                };

                // Adding the Status to Db
                _statusRepository.AddStatus(newStatus);
            }
        }
Beispiel #6
0
        public async Task <IActionResult> CreateStatus([FromBody] StatusResource statusResource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var status = mapper.Map <StatusResource, Status>(statusResource);

            repository.AddStatus(status);
            await unitOfWork.Complete();

            status = await repository.GetStatus(status.StatusId);

            var result = mapper.Map <Status, StatusResource>(status);

            return(Ok(result));
        }
Beispiel #7
0
        public ActionResult Create([Bind(Include = "Id,Name")] Status status)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    StatusRepository.AddStatus(status);
                    StatusRepository.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException dx)
            {
                ModelState.AddModelError("", dx.ToString());
            }

            return(View(status));
        }
Beispiel #8
0
        public ActionResult CreateStatus(StatusViewModel model)
        {
            try
            {
                Status s = new Status();
                statusRepo.AddStatus(s);
                s.St = model.Name;

                statusRepo.SaveChanges();
                TempData["message"] = "The status was succesfully created.";
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(RedirectToAction("CreateStatus"));
            }
            return(RedirectToAction("Index"));
        }
Beispiel #9
0
 public IActionResult PostStatus([FromBody] Status Status)
 {
     _context.AddStatus(Status);
     return(Ok());
 }