public async Task <IActionResult> ContactEdit(MN_ContactSubmit model) { var result = new MessageReport(false, "error"); //Kiểm tra là mới hay cũ cập nhật var existed = await _MN_ContactService.GetById(model.Id); if (existed == null) { existed = new MN_Contact() { Id = ObjectId.GenerateNewId().ToString(), CustomerId = model.CustomerId, ContactType = model.ContactType, Value = model.Value }; result = await _MN_ContactService.Create(existed); } else { existed.Value = model.Value; existed.ContactType = model.ContactType; result = await _MN_ContactService.Update(existed); } return(Json(result)); }
public async Task <MessageReport> Update(MN_Contact model) { var query = new StringBuilder(); query.AppendLine("{"); query.AppendLine("'_id': { '$eq': '" + model.Id + "' }"); query.AppendLine("}"); return(await _MN_ContactRepository.Update(MongoHelper.ConvertQueryStringToDocument(query.ToString()), model)); }
public async Task <IActionResult> NewContactPartial(MN_Contact model) { return(PartialView(model)); }
public async Task <MessageReport> Create(MN_Contact model) { return(await _MN_ContactRepository.Add(model)); }