public async Task <ActionResult> AddApplication(Common.Application newApp) { if (newApp == null) { return new ActionResult { IsSucceeded = false, Message = "Null object received." } } ; var res = new ActionResult(); using (var db = new DBEntities()) { try { db.Applications.Add(newApp.ToApplication()); await db.SaveChangesAsync(); res.IsSucceeded = true; } catch (Exception ex) { res.IsSucceeded = false; res.Message = ex.Message; res.ErrorMetadata = ex.StackTrace; } } return(res); } #endregion }
public async Task <IHttpActionResult> Put([FromBody] Common.Application app) { var res = await DataFacade.Current.AddApplication(app); if (!res.IsSucceeded) { //TODO: Log in file if is ON return(StatusCode(HttpStatusCode.InternalServerError)); } return(Ok(res)); }
public static DataAccess.Application ToApplication(this Common.Application application) { if (application == null) { return(null); } return(new DataAccess.Application { Id = application.Id, Name = application.Name, AppStoreIdentifier = application.AppStoreIdentifier, Description = application.Description, RegisterationUtcDate = application.RegisterationUtcDate }); }