Exemple #1
0
        public string Delete(int id)
        {
            string result = "";

            try
            {
                using (SEDESOLEntities db = new SEDESOLEntities())
                {
                    SOUP_KITCHEN_USER_TYPE att = db.SOUP_KITCHEN_USER_TYPE.FirstOrDefault(v => v.Id == id);
                    if (att != null)
                    {
                        db.SOUP_KITCHEN_USER_TYPE.Remove(att);
                        db.SaveChanges();
                        result = "SUCCESS";
                    }
                    else
                    {
                        result = "No se pudo eliminar el nivel de aprobación.";
                    }
                }
            }
            catch (Exception ex)
            {
                result = "No se pudo eliminar el nivel de aprobación";
            }
            return(result);
        }
Exemple #2
0
        public SkUserTypeDTOcs SaveUserTypeSK(SkUserTypeDTOcs dto)
        {
            try
            {
                using (SEDESOLEntities db = new SEDESOLEntities())
                {
                    SOUP_KITCHEN_USER_TYPE ut = db.SOUP_KITCHEN_USER_TYPE.FirstOrDefault(v => v.Id_UserType == dto.Id_UserType && v.Id_SoupKitchen == dto.Id_SoupKitchen);
                    if (ut != null)
                    {
                        dto.Message = "Se ha ingresado previamente.";
                    }
                    else
                    {
                        ut = new SOUP_KITCHEN_USER_TYPE();
                        ut.Id_SoupKitchen = dto.Id_SoupKitchen;
                        ut.Id_UserType    = dto.Id_UserType;
                        ut.IsActive       = true;
                        db.SOUP_KITCHEN_USER_TYPE.Add(ut);

                        if (db.SaveChanges() > 0)
                        {
                            dto.Id      = ut.Id;
                            dto.Message = "SUCCESS";
                        }
                    }
                    return(dto);
                }
            }
            catch (Exception ex)
            {
                return(new SkUserTypeDTOcs());
            }
        }