Пример #1
0
        public ActionResult AddDestinationInterest(int destinationId)
        {
            _CheckForAdminAccess();

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

            return(View(model));
        }
Пример #2
0
        public async Task <ActionResult> SaveDestinationInterestAsync(DestinationInterest model)
        {
            _CheckForAdminAccess();

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

            return(RedirectToAction("EditDestination", new { @id = model.DestinationId }));
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static async Task <DomingoBlError> SaveDestinationInterest(DestinationInterest model)
        {
            try
            {
                using (var context = new TravelogyDevEntities1())
                {
                    // create new
                    if (model.Id == 0)
                    {
                        context.DestinationInterests.Add(model);
                        await context.SaveChangesAsync();
                    }

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

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

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