internal ContactOwner Create(ContactOwner ContactOwner)
 {
     try
     {
         int maxContactOwnerId = 1;
         if (context.ContactOwner.ToList().Count > 0)
         {
             maxContactOwnerId = context.ContactOwner.Max(m => m.Contact_Owner_Id);
         }
         maxContactOwnerId = (maxContactOwnerId == 1 && context.ContactOwner.ToList().Count > 0) ? (maxContactOwnerId + 1) : maxContactOwnerId;
         ContactOwner.Contact_Owner_Code = "RT" + maxContactOwnerId + "CTOCODE" + (maxContactOwnerId + 1);
         if (ContactOwner.Contact_Status == eStatus.Active.ToString())
         {
             List <ContactOwner> _ContactOwner = context.ContactOwner.ToList();
             foreach (var item in _ContactOwner)
             {
                 item.Contact_Status       = eStatus.InActive.ToString();
                 context.Entry(item).State = System.Data.Entity.EntityState.Modified;
                 context.SaveChanges();
             }
         }
         context.ContactOwner.Add(ContactOwner);
         context.SaveChanges();
         return(ContactOwner);
     }
     catch (Exception ex)
     {
         ContactOwner.ErrorMessage = ex.Message;
         return(ContactOwner);
     }
 }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = ConfigurationSettings.AppSettings["AppName"].ToString() + " : Contact Owner Detail";
            if (Request.QueryString["ContactOwnerid"] != null)
            {
                if (!IsPostBack)
                {
                    hdnContactOwnerId.Value = Request.QueryString["ContactOwnerid"].ToString();
                    int ContactOwnerId = Convert.ToInt32(Request.QueryString["ContactOwnerid"].ToString());

                    ContactOwner _ContactOwner = bContactOwner.List().Where(m => m.Contact_Owner_Id == ContactOwnerId).FirstOrDefault();

                    txtTitle.Text            = _ContactOwner.Contact_Title;
                    txtDescription.Text      = _ContactOwner.Contact_Description;
                    chkIsDefault.Checked     = (_ContactOwner.Contact_Status == eStatus.Active.ToString()) ? true : false;
                    chkSubmitRequest.Checked = (_ContactOwner.Contact_Query_Submission == "Y") ? true : false;
                    txtAddress.Text          = _ContactOwner.Contact_Address;
                    txtCity.Text             = _ContactOwner.Contact_City;
                    txtState.Text            = _ContactOwner.Contact_State;
                    txtZip.Text     = _ContactOwner.Contact_ZipCode.ToString();
                    txtEmailId.Text = _ContactOwner.Contact_EmailId;
                    txtPhone.Text   = _ContactOwner.Contact_Phone;
                    txtFax.Text     = _ContactOwner.Contact_Fax;
                    txtWebSite.Text = _ContactOwner.Contact_WebSite;
                    txtGMapUrl.Text = _ContactOwner.Contact_GoogleMapURL;
                    lblBcTitle.Text = _ContactOwner.Contact_Title;
                }
            }
        }
Exemplo n.º 3
0
        public ContactOwner ContactUs()
        {
            ContactOwner contactOwner = new ContactOwner();

            contactOwner = bContactOwner.List().Where(m => m.Contact_Status == eStatus.Active.ToString()).FirstOrDefault();
            return(contactOwner);
        }
        public ICommandResult Handle(CreateContactOwnerCommand command)
        {
            if (_contactOwnerRepository.UserExists(command.UserName))
            {
                AddNotification("UserName", "Este usuário já esta sendo ultilizado!");
                return(null);
            }



            var name         = new Name(command.FirstName, command.LastName);
            var email        = new Email(command.Address);
            var user         = new User(command.UserName, command.Password);
            var contactOwner = new ContactOwner(user, name, email);


            AddNotifications(name.Notifications);
            AddNotifications(email.Notifications);
            AddNotifications(user.Notifications);

            if (Invalid)
            {
                return(null);
            }

            _contactOwnerRepository.Save(contactOwner);

            return(new CreateContactOwnerResult());
        }
 internal int Delete(ContactOwner ContactOwner)
 {
     try
     {
         context.Entry(ContactOwner).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
         return(100);
     }
     catch (Exception ex)
     {
         ContactOwner.ErrorMessage = ex.Message;
         return(404);
     }
 }
Exemplo n.º 6
0
        public static int Delete(ContactOwner ContactOwner)
        {
            dContactOwner _dContactOwner = new dContactOwner();

            if (Convert.ToBoolean(ConfigurationSettings.AppSettings["IsEmailEnable"]))
            {
                string mailBody = MailHelper.ActivityMail("Contact Detail", "Contact Owner Deletion done on " + ContactOwner.Contact_Address +
                                                          "( " + ContactOwner.Contact_Owner_Id + "  and " + ContactOwner.Contact_Owner_Code + " ) successfully.",
                                                          1, DateTime.Now.ToString());

                MailHelper.SendEmail(MailHelper.EmailToSend(), "Contact Owner Deletion", mailBody, "Rachna Teracotta : Activity Admin");
            }
            return(_dContactOwner.Delete(ContactOwner));
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ContactOwner ContactOwner1 = bContactOwner.List().Where(m => m.Contact_Title == txtTitle.Text.Trim()).FirstOrDefault();

            if (ContactOwner1 == null)
            {
                int          adminId      = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString());
                ContactOwner ContactOwner = new ContactOwner()
                {
                    Contact_Title            = txtTitle.Text.Trim(),
                    Contact_Status           = (chkIsDefault.Checked) ? eStatus.Active.ToString() : eStatus.InActive.ToString(),
                    Contact_Query_Submission = (chkSubmitRequest.Checked) ? "Y" : "N",
                    Contact_Description      = txtDescription.Text,
                    Contact_Address          = txtAddress.Text,
                    Contact_City             = txtCity.Text,
                    Contact_State            = txtState.Text,
                    Contact_ZipCode          = Convert.ToInt32(txtZip.Text),
                    Contact_EmailId          = txtEmailId.Text,
                    Contact_Phone            = txtPhone.Text,
                    Contact_Fax          = txtFax.Text,
                    Contact_WebSite      = txtWebSite.Text,
                    Contact_GoogleMapURL = txtGMapUrl.Text,
                    Contact_CreatedDate  = DateTime.Now,
                    Contact_UpdatedDate  = DateTime.Now,
                    Administrators_Id    = adminId
                };

                ContactOwner = bContactOwner.Create(ContactOwner);

                if (String.IsNullOrEmpty(ContactOwner.ErrorMessage))
                {
                    Response.Redirect("/administration/application/contact.aspx?id=100&redirecturl=admin-Logo-rachna-teracotta");
                }
                else
                {
                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblMessage.Text = "Failed!" + ContactOwner.ErrorMessage;
                }
            }
            else
            {
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "Oops!! ContactOwner detail not updated successfully, because ContactOwner name should not be same as other";
            }
        }
 internal ContactOwner Update(ContactOwner ContactOwner)
 {
     try
     {
         context.Entry(ContactOwner).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
         UpdateAllInactive(ContactOwner.Contact_Owner_Id);
         return(ContactOwner);
     }
     catch (Exception ex)
     {
         ContactOwner.ErrorMessage = ex.Message;
         return(ContactOwner);
     }
 }
        public ActionResult Edit(ClientViewModel model)
        {
            var client = DbSession.Query <Client>().FirstOrDefault(r => r.Id == model.ClientId);

            if (client == null)
            {
                ModelState.AddModelError("", $"Клиент с идентификатором {model.ClientId} не найден.");
                return(View(model));
            }

            uint ownerId;
            var  contactGroup = client.ContactGroups.FirstOrDefault(r => r.ContactGroupTypeId == ContactGroupType.Marketing);

            if (contactGroup == null)
            {
                var owner = new ContactOwner();
                DbSession.Save(owner);
                ownerId = owner.Id;
                DbSession.CreateSQLQuery(@"
insert into Contacts.Contact_groups (Id, Name, `Type`, ContactGroupOwnerId)
	values (:ownerId, 'Маркетинг', :groupType, :groupOwnerId);"    )
                .SetParameter("ownerId", owner.Id)
                .SetParameter("groupType", ContactGroupType.Marketing)
                .SetParameter("groupOwnerId", client.ContactGroupOwnerId)
                .ExecuteUpdate();
            }
            else
            {
                ownerId = contactGroup.Id;
            }

            var email = DbSession.Query <Contact>().FirstOrDefault(r => r.ContactOwnerId == ownerId && r.ContactType == ContactType.Email);

            if (string.IsNullOrWhiteSpace(model.Email))
            {
                if (email != null)
                {
                    DbSession.Delete(email);
                }
            }
            else
            {
                if (email == null)
                {
                    email = new Contact {
                        ContactType    = ContactType.Email,
                        ContactOwnerId = ownerId
                    };
                }
                email.ContactText = model.Email;
                DbSession.SaveOrUpdate(email);
            }

            var phone = DbSession.Query <Contact>().FirstOrDefault(r => r.ContactOwnerId == ownerId && r.ContactType == ContactType.Phone);

            if (string.IsNullOrWhiteSpace(model.Phone))
            {
                if (phone != null)
                {
                    DbSession.Delete(phone);
                }
            }
            else
            {
                if (phone == null)
                {
                    phone = new Contact {
                        ContactType    = ContactType.Phone,
                        ContactOwnerId = ownerId
                    };
                }
                phone.ContactText = model.Phone;
                DbSession.SaveOrUpdate(phone);
            }

            return(RedirectToAction("Index"));
        }
Exemplo n.º 10
0
 public void Update(ContactOwner contactOwner)
 {
     _context.Entry(contactOwner).State = EntityState.Modified;
 }
Exemplo n.º 11
0
 public void Save(ContactOwner contactOwner)
 {
     _context.ContactOwners.Add(contactOwner);
 }