Пример #1
0
        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
    }
Пример #2
0
        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));
        }
Пример #3
0
        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
            });
        }