Beispiel #1
0
        internal Keep EditKeep(Keep editedKeep, string userId)
        {
            Keep original = _repo.GetById(editedKeep.Id);

            if (original == null)
            {
                throw new Exception("Invalid Id... from keepsService");
            }

            if (original.CreatorId != userId)
            {
                throw new Exception("NOT AUTHORIZED... from keepsService");
            }



            editedKeep.Name        = editedKeep.Name == null ? original.Name : editedKeep.Name;
            editedKeep.Description = editedKeep.Description == null ? original.Description : editedKeep.Description;
            editedKeep.Img         = editedKeep.Img == null ? original.Img : editedKeep.Img;
            editedKeep.Views       = editedKeep.Views == 0 ? original.Views : editedKeep.Views;
            editedKeep.Keeps       = editedKeep.Keeps == 0 ? original.Keeps : editedKeep.Keeps;
            editedKeep.Creator     = editedKeep.Creator == null ? original.Creator : editedKeep.Creator;

            return(_repo.EditKeep(editedKeep));
        }
Beispiel #2
0
 internal string EditKeep(Keep keepToUpdate)
 {
     if (_repo.EditKeep(keepToUpdate))
     {
         return("Keep successfully updated.");
     }
     throw new Exception("Could not update keep");
 }