public object AddOrEdit(Entities.Core.PrintedReport printedReport) { if (printedReport == null) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.MethodNotAllowed)); } try { return(this.PrintedReportRepository.AddOrEdit(printedReport)); } catch (UnauthorizedException) { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.Forbidden)); } catch (MixERPException ex) { throw new HttpResponseException(new HttpResponseMessage { Content = new StringContent(ex.Message), StatusCode = HttpStatusCode.InternalServerError }); } catch { throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
/// <summary> /// Updates the row of the table "core.printed_reports" with an instance of "PrintedReport" class against the primary key value. /// </summary> /// <param name="printedReport">The instance of "PrintedReport" class to update.</param> /// <param name="id">The value of the column "id" which will be updated.</param> /// <exception cref="UnauthorizedException">Thown when the application user does not have sufficient privilege to perform this action.</exception> public void Update(Entities.Core.PrintedReport printedReport, long id) { if (string.IsNullOrWhiteSpace(this._Catalog)) { return; } if (!this.SkipValidation) { if (!this.Validated) { this.Validate(AccessTypeEnum.Edit, this._LoginId, this._Catalog, false); } if (!this.HasAccess) { Log.Information("Access to edit entity \"PrintedReport\" with Primary Key {PrimaryKey} was denied to the user with Login ID {LoginId}. {PrintedReport}", id, this._LoginId, printedReport); throw new UnauthorizedException("Access is denied."); } } Factory.Update(this._Catalog, printedReport, id, "core.printed_reports", "id"); }
/// <summary> /// Inserts the instance of PrintedReport class on the database table "core.printed_reports". /// </summary> /// <param name="printedReport">The instance of "PrintedReport" class to insert.</param> /// <exception cref="UnauthorizedException">Thown when the application user does not have sufficient privilege to perform this action.</exception> public object Add(Entities.Core.PrintedReport printedReport) { if (string.IsNullOrWhiteSpace(this._Catalog)) { return(null); } if (!this.SkipValidation) { if (!this.Validated) { this.Validate(AccessTypeEnum.Create, this._LoginId, this._Catalog, false); } if (!this.HasAccess) { Log.Information("Access to add entity \"PrintedReport\" was denied to the user with Login ID {LoginId}. {PrintedReport}", this._LoginId, printedReport); throw new UnauthorizedException("Access is denied."); } } return(Factory.Insert(this._Catalog, printedReport, "core.printed_reports", "id")); }
public object AddOrEdit(Entities.Core.PrintedReport printedReport) { if (string.IsNullOrWhiteSpace(this._Catalog)) { return(null); } printedReport.AuditUserId = this._UserId; printedReport.AuditTs = System.DateTime.UtcNow; object primaryKeyValue = printedReport.Id; if (Cast.To <long>(primaryKeyValue) > 0) { primaryKeyValue = printedReport.Id; this.Update(printedReport, printedReport.Id); } else { primaryKeyValue = this.Add(printedReport); } return(primaryKeyValue); }