Ejemplo n.º 1
0
        public RequestResponse DeleteSingleContact(int id)
        {
            RequestResponse RequestResponse = new RequestResponse();

            try
            {
                //First check if its used in project already
                bool ifExist = new ContactCRUD().CheckIfContactAsocWithProject(id);
                if (ifExist == true)
                {
                    RequestResponse.Message = "Not deleted, Record is used in Project.";
                    RequestResponse.Success = false;
                    return(RequestResponse);
                }

                new ContactCRUD().DeleteSingle(id);
                RequestResponse.Message = "Record deleted";
                RequestResponse.Success = true;
            }
            catch (Exception ex)
            {
                RequestResponse.Message = ex.Message;
                RequestResponse.Success = false;
            }

            return(RequestResponse);
        }
Ejemplo n.º 2
0
        public PartialViewResult Edit(int id)
        {
            var         entity    = __db.Contact.Find(id);
            ContactCRUD viewmodel = new ContactCRUD();

            viewmodel.ddlContactStatus = __db.ContactStatus.Select(s => new SelectListItem
            {
                Text  = s.Name,
                Value = s.Id.ToString(),
            });
            ViewBag.Title = entity.HoTen + " > " + entity.Email;
            viewmodel.InjectFrom(entity);
            return(PartialView(viewmodel));
        }
Ejemplo n.º 3
0
        public JsonResult Edit(ContactCRUD viewmodel)
        {
            rs r;

            try
            {
                var entity = __db.Contact.Find(viewmodel.Id);
                entity.GhiChu          = viewmodel.GhiChu;
                entity.ModifiedDate    = DateTime.Now;
                entity.ContactStatusId = viewmodel.ContactStatusId;
                __db.SaveChanges();
                //

                r = rs.T("Okay!");
            }
            catch (Exception ex)
            {
                r = rs.F(ex.Message);
            }

            return(Json(r, JsonRequestBehavior.DenyGet));
        }