Пример #1
0
        public string UpdateRestaurantEvent(RestaurantEvent restaurantEvent)
        {
            string message;

            try
            {
                using (var context = new DBModels())
                {
                    var eventRest = context.RestaurantEvent.FirstOrDefault(x => x.RestaurantEventID == restaurantEvent.RestaurantEventID);
                    if (eventRest == null)
                    {
                        message = RestaurantEventMessage.NokUpdate;
                    }
                    else
                    {
                        eventRest.EventTitle           = restaurantEvent.EventTitle;
                        eventRest.EventDescription     = restaurantEvent.EventDescription;
                        eventRest.EventStartDate       = restaurantEvent.EventStartDate;
                        eventRest.EventEndDate         = restaurantEvent.EventEndDate;
                        context.Entry(eventRest).State = EntityState.Modified;
                        context.SaveChanges();
                        message = RestaurantEventMessage.OkUpdate;
                    }
                }
            }
            catch (Exception ex)
            {
                _logger.Log("UpdateRestaurantEvent_Exception", ex.Message);
                return(message = RestaurantEventMessage.NokUpdate);
            }
            return(message);
        }
Пример #2
0
        public string SaveRestaurantEvent(RestaurantEvent restaurantEvent)
        {
            string saveMessage;

            try
            {
                using (var context = new DBModels())
                {
                    context.RestaurantEvent.Add(restaurantEvent);
                    context.SaveChanges();
                    saveMessage = RestaurantEventMessage.OkMessage;
                }
            }
            catch (Exception ex)
            {
                saveMessage = RestaurantEventMessage.NokMessage;
                _logger.Log("SaveRestaurantEvent_Exception", ex.Message);
            }
            return(saveMessage);
        }