Ejemplo n.º 1
0
 public ServiceResponse Save(TagsModel model)
 {
     try
     {
         using (var ts = new TransactionScope(TransactionScopeOption.Required))
         {
             Core_Tags obj = new Core_Tags
             {
                 Name = model.Name,
             };
             _ent.AddToCore_Tags(obj);
             _ent.SaveChanges();
             ts.Complete();
             _response = new ServiceResponse("Record successfully created!!", MessageType.Success, true, "Edit");
             return(_response);
         }
     }
     catch (SqlException ex)
     {
         _response = new ServiceResponse(ServiceResponsesProvider.SqlExceptionMessage(ex), MessageType.SqlException, false);
     }
     catch (Exception ex)
     {
         _response = new ServiceResponse(ex.Message, MessageType.Exception, false, "Edit");
     }
     return(_response);
 }
Ejemplo n.º 2
0
        public App_Class.ServiceResponse Delete(int PId)
        {
            Core_Tags result = _ent.Core_Tags.Where(x => x.TagId == PId).FirstOrDefault();

            try
            {
                _ent.DeleteObject(result);
                _ent.SaveChanges();
                _response = new ServiceResponse("Successfully deleted!!", MessageType.Success, true, "Delete");
                return(_response);
            }
            catch (SqlException ex)
            {
                _response = new ServiceResponse(ServiceResponsesProvider.SqlExceptionMessage(ex), MessageType.SqlException, false);
            }
            catch (Exception ex)
            {
                _response = new ServiceResponse(ex.Message, MessageType.Exception, false, "Delete");
            }
            return(_response);
        }