예제 #1
0
 internal SocialNetworking Update(SocialNetworking SocialNetworking)
 {
     try
     {
         context.Entry(SocialNetworking).State = System.Data.Entity.EntityState.Modified;
         context.SaveChanges();
         return(SocialNetworking);
     }
     catch (Exception ex)
     {
         SocialNetworking.ErrorMessage = ex.Message;
         return(SocialNetworking);
     }
 }
예제 #2
0
 internal int Delete(SocialNetworking SocialNetworking)
 {
     try
     {
         context.Entry(SocialNetworking).State = System.Data.Entity.EntityState.Deleted;
         context.SaveChanges();
         return(100);
     }
     catch (Exception ex)
     {
         SocialNetworking.ErrorMessage = ex.Message;
         return(404);
     }
 }
        public static int Delete(SocialNetworking SocialNetworking)
        {
            dSocialNetworking _dSocialNetworking = new dSocialNetworking();

            if (Convert.ToBoolean(ConfigurationSettings.AppSettings["IsEmailEnable"]))
            {
                string mailBody = MailHelper.ActivityMail("Social Networking", "Social Networking Deletion done on " +
                                                          "( " + SocialNetworking.Scl_Ntk_Id + "  and " + SocialNetworking.Scl_Ntk_Code + " ) successfully.",
                                                          SocialNetworking.Administrators_Id, DateTime.Now.ToString());

                MailHelper.SendEmail(MailHelper.EmailToSend(), "Social Networking Deletion", mailBody, "Rachna Teracotta : Activity Admin");
            }
            return(_dSocialNetworking.Delete(SocialNetworking));
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            int adminId                = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString());
            int SocialNetworkingId     = Convert.ToInt32(hdnSocialNetworkingId.Value);
            SocialNetworking _otherStr = bSocialNetworking.List().Where(m => m.Scl_Ntk_Id != SocialNetworkingId && m.Scl_Ntk_URL == txtTitle.Text.Trim()).FirstOrDefault();

            if (_otherStr == null)
            {
                SocialNetworking SocialNetworking = bSocialNetworking.List().Where(m => m.Scl_Ntk_Id == SocialNetworkingId).FirstOrDefault();
                SocialNetworking.Scl_Ntk_URL         = txtTitle.Text;
                SocialNetworking.Scl_Ntk_Status      = (chkIsDefault.Checked) ? eStatus.Active.ToString() : eStatus.InActive.ToString();
                SocialNetworking.Scl_Ntk_UpdatedDate = DateTime.Now;
                SocialNetworking.Administrators_Id   = adminId;
                if (imgInp.HasFile)
                {
                    SocialNetworking.Scl_Ntk_Icon = "files/SocialNetworking/" + "SocialNetworking_" + SocialNetworking.Scl_Ntk_Id + ".png";
                    string   path = Server.MapPath("../" + SocialNetworking.Scl_Ntk_Icon);
                    FileInfo file = new FileInfo(path);
                    if (file.Exists)//check file exsit or not
                    {
                        file.Delete();
                    }
                    Upload(SocialNetworking.Scl_Ntk_Id);
                }

                SocialNetworking = bSocialNetworking.Update(SocialNetworking);

                if (String.IsNullOrEmpty(SocialNetworking.ErrorMessage))
                {
                    Response.Redirect("/administration/application/socialnetwork.aspx?id=100&redirecturl=admin-SocialNetworking-rachna-teracotta");
                }
                else
                {
                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblMessage.Text = "Failed!" + SocialNetworking.ErrorMessage;
                }
            }
            else
            {
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "Oops!! SocialNetworking detail not updated successfully, because SocialNetworking name should not be same as other";
            }
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            SocialNetworking SocialNetworking1 = bSocialNetworking.List().Where(m => m.Scl_Ntk_URL == txtTitle.Text.Trim()).FirstOrDefault();

            if (SocialNetworking1 == null)
            {
                int adminId = Convert.ToInt32(Session[ConfigurationSettings.AppSettings["AdminSession"].ToString()].ToString());
                SocialNetworking SocialNetworking = new SocialNetworking()
                {
                    Scl_Ntk_URL         = txtTitle.Text.Trim(),
                    Scl_Ntk_Icon        = "files/SocialNetworking/" + "SocialNetworking_" + imgInp.FileName,
                    Scl_Ntk_Status      = (chkIsDefault.Checked) ? eStatus.Active.ToString() : eStatus.InActive.ToString(),
                    Scl_Ntk_CreatedDate = DateTime.Now,
                    Scl_Ntk_UpdatedDate = DateTime.Now,
                    Administrators_Id   = adminId
                };

                SocialNetworking = bSocialNetworking.Create(SocialNetworking);

                if (String.IsNullOrEmpty(SocialNetworking.ErrorMessage))
                {
                    Upload();

                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-success alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblMessage.Text = "SocialNetworking Detail Updated Successfully";
                    ClearFields();
                }
                else
                {
                    pnlErrorMessage.Attributes.Remove("class");
                    pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                    pnlErrorMessage.Visible             = true;
                    lblMessage.Text = "Failed!" + SocialNetworking.ErrorMessage;
                }
            }
            else
            {
                pnlErrorMessage.Attributes.Remove("class");
                pnlErrorMessage.Attributes["class"] = "alert alert-danger alert-dismissable";
                pnlErrorMessage.Visible             = true;
                lblMessage.Text = "Oops!! SocialNetworking detail not updated successfully, because SocialNetworking name should not be same as other";
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Title = ConfigurationSettings.AppSettings["AppName"].ToString() + " : SocialNetworking";
            if (Request.QueryString["SocialNetworkingid"] != null)
            {
                if (!IsPostBack)
                {
                    hdnSocialNetworkingId.Value = Request.QueryString["SocialNetworkingid"].ToString();
                    int SocialNetworkingId = Convert.ToInt32(Request.QueryString["SocialNetworkingid"].ToString());

                    SocialNetworking _SocialNetworking = bSocialNetworking.List().Where(m => m.Scl_Ntk_Id == SocialNetworkingId).FirstOrDefault();

                    txtTitle.Text        = _SocialNetworking.Scl_Ntk_URL;
                    chkIsDefault.Checked = (_SocialNetworking.Scl_Ntk_Status == eStatus.Active.ToString()) ? true : false;
                    imgArticle.ImageUrl  = "~/" + _SocialNetworking.Scl_Ntk_Icon;
                    lblBcTitle.Text      = _SocialNetworking.Scl_Ntk_URL;
                }
            }
        }
예제 #7
0
 internal SocialNetworking Create(SocialNetworking SocialNetworking)
 {
     try
     {
         int maxSocialNetworkingId = 1;
         if (context.SocialNetworking.ToList().Count > 0)
         {
             maxSocialNetworkingId = context.SocialNetworking.Max(m => m.Scl_Ntk_Id);
         }
         maxSocialNetworkingId         = (maxSocialNetworkingId == 1 && context.SocialNetworking.ToList().Count > 0) ? (maxSocialNetworkingId + 1) : maxSocialNetworkingId;
         SocialNetworking.Scl_Ntk_Code = "RT" + maxSocialNetworkingId + "SLNCODE" + (maxSocialNetworkingId + 1);
         context.SocialNetworking.Add(SocialNetworking);
         context.SaveChanges();
         return(SocialNetworking);
     }
     catch (Exception ex)
     {
         SocialNetworking.ErrorMessage = ex.Message;
         return(SocialNetworking);
     }
 }