Exemplo n.º 1
0
        public ActionResult AddDestinationActivity(int destinationId)
        {
            _CheckForAdminAccess();

            var model = new DestinationActivity()
            {
                DestinationId = destinationId
            };

            return(View(model));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> SaveDestinationActivityAsync(DestinationActivity model)
        {
            _CheckForAdminAccess();

            if (model != null)
            {
                await AdminUtility.SaveDestinationActivity(model);
            }

            return(RedirectToAction("EditDestination", new { @id = model.DestinationId }));
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static async Task <DomingoBlError> SaveDestinationActivity(DestinationActivity model)
        {
            try
            {
                using (var context = new TravelogyDevEntities1())
                {
                    // create new
                    if (model.Id == 0)
                    {
                        context.DestinationActivities.Add(model);
                        await context.SaveChangesAsync();
                    }

                    // update existing
                    else
                    {
                        var _dbActivityObj = context.DestinationActivities.Find(model.Id);
                        if (_dbActivityObj != null)
                        {
                            _dbActivityObj.Name          = model.Name;
                            _dbActivityObj.ThumbnailPath = model.ThumbnailPath;
                            _dbActivityObj.Type          = model.Type;
                            _dbActivityObj.Description   = model.Description;

                            await context.SaveChangesAsync();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                return(new DomingoBlError()
                {
                    ErrorCode = 100, ErrorMessage = ex.Message
                });
            }

            return(new DomingoBlError()
            {
                ErrorCode = 0, ErrorMessage = ""
            });
        }