Пример #1
0
 public ResultEnum UpdateActivity(Activity activity)
 {
     try
     {
         manager.Update(activity);
         return ResultEnum.Success;
     }
     catch
     {
         return ResultEnum.Fail;
     }
 }
Пример #2
0
        public ResultEnum AddActivity(Activity activity)
        {
            ResultEnum result;

            try
            {
                manager.Create(activity);
                result = ResultEnum.Success;
            }
            catch
            {
                result = ResultEnum.Fail;
            }

            return result;
        }
Пример #3
0
        public ActionResult Add(ActivitiesViewModel model)
        {
            string errorMessage = "Unable to add the activity to the package.";
            string successMessage = "The activity has been added to your package.";

            if (ModelState.IsValid)
            {
                try
                {
                    // Get co-ordianates of address
                    IGeolocationService geolocationService = UtilityFactory.GetGeolocationService();
                    Location location = geolocationService.GetCoordinates(
                        String.Format("{0}, {1}, {2}", model.Address, model.PackageCity, model.PackageState.ToString()));

                    Activity activity = new Activity()
                    {
                        Name = model.ActivityName,
                        Description = model.Description,
                        Address = model.Address,
                        Status = PackageStatusEnum.Available,
                        PackageId = model.PackageId,
                        Latitude = location.Latitude,
                        Longitude = location.Longitude
                    };

                    ResultEnum result = activityService.AddActivity(activity);

                    if (result == ResultEnum.Success)
                    {
                        model.SuccessMessage = successMessage;
                    }
                    else
                    {
                        model.ErrorMessage = errorMessage;
                    }

                    return View(model);
                }
                catch
                {
                    model.ErrorMessage = errorMessage;
                }
            }

            return View(model);
        }