Exemple #1
0
        // DELETE: odata/BO_User(5)
        public async Task <IHttpActionResult> Delete([FromODataUri] int key)
        {
            BO_User bO_User = await db.BO_User.FindAsync(key);

            if (bO_User == null)
            {
                return(NotFound());
            }

            db.BO_User.Remove(bO_User);
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #2
0
        // POST: odata/BO_User
        public async Task <IHttpActionResult> Post(BO_User bO_User)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            else
            {
                var username = bO_User.Name + bO_User.Surname[0];
                bO_User.User_Name = username;

                db.BO_User.Add(bO_User);
                await db.SaveChangesAsync();

                MailMessage email      = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("mail.software-solutions.co.za");
                email.From = new MailAddress(ConfigurationManager.AppSettings["FromEmailAddress"].ToString());
                email.To.Add(bO_User.Email);
                email.Subject = "eMIS Activation";
                SqlHelper sql = new SqlHelper();
                sql.AddVarCharInputParam("@username", username, 100);
                sql.AddVarCharInputParam("@password", bO_User.Password, 100);
                DataSet ds = sql.GetDataSet("spGetUserByEmailPassword", ConfigurationManager.ConnectionStrings["eMIS_Reporting"].ToString());
                email.Body = "Welcome to emis follow the link to activate your email" + Environment.NewLine + Environment.NewLine + "http://localhost:63416/EmailConfirmationPage.html?email=" + ds.Tables[0].Rows[0][0];

                //System.Net.Mail.Attachment attachment;
                //attachment = new Attachment(path + Convert.ToString(id) + quoteorinvoice + time + ".pdf");
                //email.Attachments.Add(attachment);

                SmtpServer.Port        = 25;
                SmtpServer.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["FromEmailAddress"].ToString(), ConfigurationManager.AppSettings["FromEmailAddressPassword"].ToString());
                SmtpServer.EnableSsl   = false;

                SmtpServer.Send(email);
            }
            return(Created(bO_User));
        }
Exemple #3
0
        // PUT: odata/BO_User(5)
        public async Task <IHttpActionResult> Put([FromODataUri] Guid key, Delta <BO_User> patch)
        {
            Validate(patch.GetEntity());

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            BO_User bO_User = await db.BO_User.FindAsync(key);

            if (bO_User == null)
            {
                return(NotFound());
            }

            patch.Put(bO_User);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BO_UserExists(key))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(Updated(bO_User));
        }