Exemplo n.º 1
0
        public IActionResult Post([FromBody] BucketlistDto dto)
        {
            BucketlistModel bucketlistModel = new BucketlistModel
            {
                Created_By    = dto.Created_By,
                Date_Created  = DateTime.Today,
                Date_Modified = DateTime.Today,
                Items         = dto.Items.Count <= 0 ? "Item not set" : "item set",
                Name          = dto.Name
            };

            _Service.Add(bucketlistModel);
            if (dto.Items.Count > 0)
            {
                foreach (var item in dto.Items)
                {
                    BucketlistItem bucketlistItem = new BucketlistItem
                    {
                        Date_Created  = DateTime.Today.Date,
                        Date_Modified = DateTime.Today.Date,
                        Done          = item.Done,
                        Name          = item.Name,
                        BucketlistId  = bucketlistModel.Id.ToString()
                    };
                    _Service.Add(bucketlistItem);
                }
            }
            _Service.Save();

            return(Ok("Added Successfully", isSuccessful: true));
        }
Exemplo n.º 2
0
        public IActionResult GetListByName(string name)
        {
            BucketlistModel item = _BucketlistLogic.GetEntityBy(p => p.Name == name);

            if (item != null)
            {
                return(Ok(item, (int)Enums.StatusCode.Success, "single bucket item", true));
            }
            return(BadRequest(null, (int)Enums.StatusCode.Error));
        }
Exemplo n.º 3
0
        public IActionResult DeleteBucketList(string id)
        {
            BucketlistModel bucketItem = _BucketlistLogic.GetEntityBy(p => p.Id.ToString() == id);

            if (bucketItem != null)
            {
                _BucketlistLogic.Delete(bucketItem);
                _Service.Save();
                return(Ok(null, (int)Enums.StatusCode.Success, "deleted successfully", true));
            }
            return(BadRequest(null, (int)Enums.StatusCode.Error, "couldn't delete"));
        }
Exemplo n.º 4
0
        public IActionResult UpdateBucketlist([FromBody] UpdateBucketlistDto dto, string id)
        {
            BucketlistModel bucketItem = _BucketlistLogic.GetEntityBy(p => p.Id.ToString() == id);

            if (bucketItem != null)
            {
                bucketItem.Created_By    = dto.Created_By;
                bucketItem.Date_Created  = dto.Date_Created;
                bucketItem.Date_Modified = DateTime.Today;
                bucketItem.Name          = dto.Name;
                _Service.Save();
                return(Ok("Updated successfully", isSuccessful: true, status: (int)Enums.StatusCode.Success));
            }
            return(BadRequest("Update failed"));
        }
Exemplo n.º 5
0
        public IActionResult AddBucklistItem([FromBody] BucketlistItemDto items, string id)
        {
            BucketlistModel bucketItem = _BucketlistLogic.GetEntityBy(p => p.Id.ToString() == id);

            if (bucketItem != null)
            {
                BucketlistItem bucketlistItem = new BucketlistItem
                {
                    Date_Created  = DateTime.Today,
                    Date_Modified = DateTime.Today,
                    Done          = items.Done,
                    Name          = items.Name,
                    BucketlistId  = bucketItem.Id.ToString()
                };
                _Service.Add(bucketlistItem);
                _Service.Save();
                return(Ok(items, (int)Enums.StatusCode.Success, isSuccessful: true));
            }
            return(BadRequest(null, (int)Enums.StatusCode.Error));
        }