public HttpResponseMessage Save(Document model) { HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.Created); try { if (model.Data.Length > 512000000) throw new ArgumentException("Размер файла превышает 50 Мб"); model.CurUserAdSid = GetCurUser().Sid; model.Save(); response.Content = new StringContent(String.Format("{{\"id\":{0}}}", model.Id)); } catch (Exception ex) { response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new StringContent(String.Format("{{\"errorMessage\":\"{0}\"}}", ex.Message)); } return response; }
public static IEnumerable<Document> GetList(int? idDepartment = null, int? idPosition = null, int? idEmployee = null) { //SqlParameter pIdDocument = new SqlParameter() { ParameterName = "id_document", SqlValue = idDocument, SqlDbType = SqlDbType.Int }; SqlParameter pIdDepartment = new SqlParameter() { ParameterName = "id_department", SqlValue = idDepartment, SqlDbType = SqlDbType.Int }; SqlParameter pIdPosition = new SqlParameter() { ParameterName = "id_position", SqlValue = idPosition, SqlDbType = SqlDbType.Int }; SqlParameter pIdEmployee = new SqlParameter() { ParameterName = "id_employee", SqlValue = idEmployee, SqlDbType = SqlDbType.Int }; var dt = Db.Stuff.ExecuteQueryStoredProcedure("get_document_list", pIdDepartment, pIdPosition, pIdEmployee); var lst = new List<Document>(); foreach (DataRow row in dt.Rows) { var dep = new Document(row); lst.Add(dep); } return lst; }