コード例 #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());
        }
コード例 #2
0
 public async Task <ActionResult> AddProjectMilestone(Status model)
 {
     if (ModelState.IsValid)
     {
         return(Ok(await _repository.AddStatus(model)));
     }
     return(BadRequest());
 }
コード例 #3
0
        public StatusResult AddStatus(StatusCreateViewModel model)
        {
            var result = _statusRepository.AddStatus(new ProductStatus {
                Name = model.Name
            });

            return(result ? StatusResult.Success : StatusResult.Failure);
        }
コード例 #4
0
ファイル: Statuses.cs プロジェクト: mtaylor99/TaskList
        public bool AddStatus(Status status)
        {
            logger.LogInformation("Statuses Business Logic - AddStatus");

            statusRepository.AddStatus(status);

            return(true);
        }
コード例 #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);
            }
        }
コード例 #6
0
ファイル: StatusController.cs プロジェクト: GedeonHuy/PMS
        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));
        }
コード例 #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));
        }
コード例 #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"));
        }
コード例 #9
0
 public IActionResult PostStatus([FromBody] Status Status)
 {
     _context.AddStatus(Status);
     return(Ok());
 }