/// <summary>
 /// Adds an activity to the Episerver Social Activity Streams system.
 /// </summary>
 /// <param name="actor">the actor who initiated the activity</param>
 /// <param name="target">the target of the activity</param>
 /// <param name="activity">an instance of CommunityActivity</param>
 /// <exception cref="SocialRepositoryException">Thrown when errors occur
 /// interacting with the Social cloud services.</exception>
 public void Add(string actor, string target, CommunityActivity activity)
 {
     try
     {
         service.Add(new Activity(
                         Reference.Create(actor),
                         Reference.Create(target)), activity
                     );
     }
     catch (SocialAuthenticationException ex)
     {
         throw new SocialRepositoryException("The application failed to authenticate with Episerver Social.", ex);
     }
     catch (MaximumDataSizeExceededException ex)
     {
         throw new SocialRepositoryException("The application request was deemed too large for Episerver Social.", ex);
     }
     catch (SocialCommunicationException ex)
     {
         throw new SocialRepositoryException("The application failed to communicate with Episerver Social.", ex);
     }
     catch (SocialException ex)
     {
         throw new SocialRepositoryException("Episerver Social failed to process the application request.", ex);
     }
 }
Пример #2
0
        public async Task Post(Activity item)
        {
            //var activationContext = FabricRuntime.GetActivationContext();

            IActivityService activityService = ServiceProxy.Create <IActivityService>(ServiceFabricHelpers.ActivitiesServiceUri);
            await activityService.Add(item);
        }
 public IActionResult Post([FromBody] ActivityModel activity)
 {
     try
     {
         return(Ok(_activityService.Add(activity.ToDomainModel())));
     }
     catch (Exception e)
     {
         ModelState.AddModelError("Post", e.Message);
         return(BadRequest(ModelState));
     }
 }
Пример #4
0
 public IActionResult Post([FromBody] ActivityModel activity)
 {
     try
     {
         _activityService.Add(activity.ToDomainModel());
     }
     catch (System.Exception ex)
     {
         ModelState.AddModelError("AddActivity", ex.GetBaseException().Message);
         return(BadRequest(ModelState));
     }
     return(CreatedAtAction("Get", new { Id = activity.Id }, activity));
 }
Пример #5
0
 public void Add(Activity activity)
 {
     try
     {
         activityService.Add(activity);
         logger.LogInformation("Activity saved " + activity);
     }
     catch (Exception ex)
     {
         logger.LogError(ex.Message);
         throw;
     }
 }
Пример #6
0
        public HttpResponseMessage PostActivity([FromBody] Models.Activity activity)
        {
            var addResult = service.Add(activity);

            if (addResult)
            {
                return(Request.CreateResponse(HttpStatusCode.Created));
            }
            else
            {
                var msg = "" + activity.Name + " was created failed";
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, msg));
            }
        }
Пример #7
0
        public IActionResult Post([FromBody] ActivityDTO ActivityDto)
        {
            var _activity = new Activity();

            _activity = _mapper.Map <Activity>(ActivityDto);

            var result = _service.Add(_activity);

            if (result.IsValid)
            {
                return(new OkObjectResult(result));
            }
            else
            {
                return(new BadRequestObjectResult(result));
            }
        }
Пример #8
0
 public ActionResult Create([FromBody] ActivityCreateModel model)
 {
     try
     {
         DateTime now      = DateTime.Now;
         Activity activity = new Activity
         {
             activityName = model.activityName,
             clubId       = model.clubId,
             eventDate    = now.Date,
             description  = model.description,
             point        = 10,
         };
         ActivityService.Add(activity);
         ActivityService.SaveChanges();
         return(Ok(activity.activityId));
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Пример #9
0
        public ActionResult Index(int page = 1, int category = 0)
        {
            var product = _productService.GetById(1);
            //var customer = _customerService.GetById(1);
            int pageSize = 10;
            var products = _productService.GetByCategory(category);
            ProductListViewModel model = new ProductListViewModel
            {
                Products       = products.Skip((page - 1) * pageSize).Take(pageSize).ToList(),
                PageCount      = (int)Math.Ceiling(products.Count / (double)pageSize),
                PageSize       = pageSize,
                CurrenCategory = category,
                CurrentPage    = page
            };

            //var data = _customerService.GetById(10);
            //_productService.Add(new Product { CategoryId=2,UnitPrice=1,UnitInStock=2,ProductName="Bu bir test Ürünüdür2"});
            //_customerService.Add(new Customer { CustomerName = "WBoard Tech", UserName = "******", UserPassword = "******", Mail = "*****@*****.**", CreatedDate = DateTime.Now.Date, UpdatedDate = DateTime.Now.Date });
            _activityService.Add(new Activity {
                CustomerId = 1, ActivitytDescription = "Test amaçlı açıldı kardo", CreatedDate = DateTime.Now.Date, UpdatedDate = DateTime.Now.Date
            });
            return(View(model));
        }
Пример #10
0
        public async Task <IActionResult> CreateActivityAsync([FromBody] ActivityDto activity)
        {
            _logger.LogInformation("CreateActivityAsync() method start.");

            var model = activity.Map();

            // Add Activity object to the database
            var addResponse = await Task.FromResult(_activityService.Add(model));

            if (addResponse.HasErrors)
            {
                if (addResponse.Exception != null)
                {
                    var exceptionMessage = $"Error in CreateActivityAsync() method.  Activity object may not have been added to database.  Exception was thrown in ActivityService.  Exception Type: '{addResponse.Exception.GetType()}'.  Exception Message: {addResponse.Exception.Message}";
                    _logger.LogError(exceptionMessage);
                    return(BadRequest(addResponse.ErrorMessage));
                }

                var message = $"Error in CreateActivityAsync() method.  Activity object may not have been added to database.  Error message returned from ActivityService: {addResponse.ErrorMessage}";
                _logger.LogError(message);
                return(NotFound(addResponse.ErrorMessage));
            }

            var addedObject = addResponse.Result;
            var dto         = addedObject.Map();
            var id          = addedObject.Id;

            _logger.LogInformation($"CreateActivityAsync() method end with Activity id '{id}'.");

            var actionResult = CreatedAtAction(
                actionName: nameof(GetActivityByIdAsync),                 // ASP.NET Core 3.0 bug: https://stackoverflow.com/questions/59288259/asp-net-core-3-0-createdataction-returns-no-route-matches-the-supplied-values
                //controllerName: ControllerContext.ActionDescriptor.ControllerName,
                routeValues: new { id },
                value: dto);

            return(actionResult);
        }
Пример #11
0
 public IHttpActionResult PostActivity(Activity activity)
 {
     activity.UserId = User.Identity.GetUserId();
     activityService.Add(activity);
     return(Ok());
 }