コード例 #1
0
        public async Task <IActionResult> UpdateCategory(RequstModels.Contact rContact)
        {
            var sCatetory = await _categoryRepository.Get(Guid.Parse(rContact.CategoryId));

            var sContact = await _contactRepository.Get(Guid.Parse(rContact.Id));

            sContact.Name     = rContact.Name;
            sContact.Email    = rContact.Email;
            sContact.Mobile   = rContact.Mobile;
            sContact.Address  = rContact.Address;
            sContact.Category = sCatetory;
            //sContact.ProfilePicture = rContact.ProfilePicture;
            sContact.ModifiedAt = DateTime.Now;
            sContact.ModifiedBy = "system";// get user from token

            var isModified = await _contactRepository.Commit();

            if (isModified)
            {
                return(Ok(new
                {
                    Status = CMAContants.Success
                }));
            }
            else
            {
                return(BadRequest(new
                {
                    Status = CMAContants.Failed
                }));
            }
        }
コード例 #2
0
        public async Task <IActionResult> AddContact(RequstModels.Contact rContact)
        {
            var sCatetory = await _categoryRepository.Get(Guid.Parse(rContact.CategoryId));

            var sContact = new DbModels.Contact
            {
                Id             = Guid.NewGuid(),
                Name           = rContact.Name,
                Email          = rContact.Email,
                Address        = rContact.Address,
                Mobile         = rContact.Mobile,
                ProfilePicture = rContact.ProfilePicture,
                Category       = sCatetory,
                CreatedBy      = "system", // get user from token
                CreatedAt      = DateTime.UtcNow,
                ModifiedBy     = "system", // get user from token
                ModifiedAt     = DateTime.UtcNow
            };

            _contactRepository.Add(sContact);
            var isAdded = await _contactRepository.Commit();

            if (isAdded)
            {
                return(Ok(new
                {
                    Status = CMAContants.Success
                }));
            }
            else
            {
                return(BadRequest(new
                {
                    Status = CMAContants.Failed
                }));
            }
        }