Пример #1
0
        public async Task <bool> InsertCompanyToCommunity(string CID, InsertCompanyViewModel company)
        {
            var com = await GetCommunity(CID);

            com.Companies.Add(new Company {
                Id          = Guid.NewGuid().ToString(), Name = company.Name,
                StartDate   = DateTime.Now, Address = company.Address, Contacts = company.Contacts,
                Description = company.Description
            });
            var result = await _Community.ReplaceOneAsync(x => x.Id == CID, com);

            return(result.IsAcknowledged);
        }
Пример #2
0
        public async Task <bool> ModifyCompany(string CID, string CoID, InsertCompanyViewModel model)
        {
            var com = await GetCommunity(CID);

            var comp = com.Companies.SingleOrDefault(x => x.Id == CoID);

            com.Companies.Remove(comp);
            comp.Name        = model.Name;
            comp.Address     = model.Address;
            comp.Contacts    = model.Contacts;
            comp.Description = model.Description;
            com.Companies.Add(comp);

            var result = await _Community.ReplaceOneAsync(x => x.Id == CID, com);

            return(result.IsAcknowledged);
        }
        public async Task <IActionResult> ModifyCompany([FromRoute] string CID, [FromRoute] string CoID, [FromBody] InsertCompanyViewModel model)
        {
            var result = await _MongocourseService.ModifyCompany(CID, CoID, model);

            if (result)
            {
                return(Ok(new { status = 1, Message = "Successfully Modified" }));
            }
            return(BadRequest());
        }