Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 public async Task <IActionResult> NewContactPartial(MN_Contact model)
 {
     return(PartialView(model));
 }
Ejemplo n.º 4
0
 public async Task <MessageReport> Create(MN_Contact model)
 {
     return(await _MN_ContactRepository.Add(model));
 }