Beispiel #1
0
        internal Restaurant Edit(Restaurant editRestaurant)
        {
            Restaurant data = GetById(editRestaurant.Id);

            editRestaurant.Name     = editRestaurant.Name != null && editRestaurant.Name.Length > 2 ? editRestaurant.Name:data.Name;
            editRestaurant.Location = editRestaurant.Location != null ? editRestaurant.Location : data.Location;
            editRestaurant.Owner    = editRestaurant.Owner != null ? editRestaurant.Owner : data.Owner;
            return(_repo.Edit(editRestaurant));
        }
Beispiel #2
0
        internal Restaurant Edit(Restaurant editData, string userId)
        {
            Restaurant original = Get(editData.Id);

            if (original.OwnerId != userId)
            {
                throw new Exception("Access Denied: Cannot Edit a Restaurant You did not Create");
            }
            editData.Name     = editData.Name == null ? original.Name : editData.Name;
            editData.Location = editData.Location == null ? original.Location : editData.Location;

            return(_repo.Edit(editData));
        }