public OneResult <ContactViewModel> Create(ContactViewModel contactView) { OneResult <ContactViewModel> resultContact = new OneResult <ContactViewModel>(); try { Contact contact = FromViewModel.FromContactView(contactView); if (_contactService.AddContact(contact)) { resultContact.Success = true; resultContact.Message = "Register was successful"; } else { resultContact.Success = false; resultContact.Message = "Register has failed"; } } catch (Exception ex) { //TODO log resultContact.Success = false; } return(resultContact); }
public OneResult <ContactViewModel> EditContact(ContactViewModel contactModel) { OneResult <ContactViewModel> resultContact = new OneResult <ContactViewModel>(); try { Contact contact = FromViewModel.FromContactView(contactModel); if (_contactService.EditContact(contact)) { resultContact.Success = true; } else { resultContact.Success = false; resultContact.Message = "Information does not change"; } } catch (Exception ex) { //TODO log resultContact.Success = false; } return(resultContact); }
void FromBimd() { using (ControlerDB db = new ControlerDB()) { DGV_Customize.DGV_Customize.DGV_Columns(dgvFrom, 0, "ID", "ID", "code", false); DGV_Customize.DGV_Customize.DGV_Columns(dgvFrom, 1, "User", "UserName", "کاربر"); DGV_Customize.DGV_Customize.DGV_Columns(dgvFrom, 2, "Book", "BookName", "کتاب"); DGV_Customize.DGV_Customize.DGV_Columns(dgvFrom, 3, "Date", "DateTime", "تاریخ"); DGV_Customize.DGV_Customize.DGV_Columns(dgvFrom, 4, "Type", "Type", "نوع"); dgvFrom.AutoGenerateColumns = false; List <FromViewModel> fromViewModels = new List <FromViewModel>(); var froms = db.FromRepository.get(); foreach (var fromTb in froms) { FromViewModel from = new FromViewModel() { Type = (fromTb.Type) ? "تحویل" : "دریافت", BookName = fromTb.BookTB.BookName, UserName = fromTb.CustomerTB.FullName, FromId = fromTb.ID, DateTime = fromTb.Date.Toshamsi() }; fromViewModels.Add(from); } dgvFrom.DataSource = fromViewModels.ToList(); } }