Exemplo n.º 1
0
        public TEUnit_Onboarding AddUnit_Onboarding(TEUnit_Onboarding value)
        {
            try
            {
                TEUnit_Onboarding result = value;

                if (!(value.Uniqueid + "".Length > 0))
                {
                    //Create
                    result.CreatedOn      = System.DateTime.Now;
                    result.LastModifiedOn = System.DateTime.Now;
                    result = db.TEUnit_Onboarding.Add(value);
                }
                else
                {
                    //Edit
                    db = new TEHRIS_DevEntities();
                    db.TEUnit_Onboarding.Attach(value);
                    foreach (System.Reflection.PropertyInfo item in result.GetType().GetProperties())
                    {
                        string propname = item.Name;
                        if (propname.ToLower() == "createdon")
                        {
                            continue;
                        }
                        object propValue = item.GetValue(value);
                        if (propValue != null || Convert.ToString(propValue).Length != 0)
                        {
                            db.Entry(value).Property(propname).IsModified = true;
                        }
                    }

                    value.LastModifiedOn = System.DateTime.Now;
                    db.Entry(value).Property(x => x.LastModifiedOn).IsModified = true;
                }
            }
            catch (Exception ex)
            {
                db.ApplicationErrorLogs.Add(
                    new ApplicationErrorLog
                {
                    Error             = ex.Message,
                    ExceptionDateTime = System.DateTime.Now,
                    InnerException    = ex.InnerException != null ? ex.InnerException.Message : "",
                    Source            = "From TEUnitonboard| AddUnit_Onboarding | " + this.GetType().ToString(),
                    Stacktrace        = ex.StackTrace
                }
                    );
            }

            db.SaveChanges();
            return(db.TEUnit_Onboarding.Find(value.Uniqueid));
        }
Exemplo n.º 2
0
        public TEDocument Post(TEDocument value)
        {
            TEDocument result = value;

            using (var scope = new System.Transactions.TransactionScope())
            {
                //Create
                if (!(value.Uniqueid + "".Length > 0))
                {
                    result.UploadedOn     = System.DateTime.Now;
                    result.LastModifiedOn = System.DateTime.Now;
                    result = db.TEDocuments.Add(value);
                }
                //Edit | Delete
                else
                {
                    db = new TEHRIS_DevEntities();
                    db.TEDocuments.Attach(value);

                    foreach (System.Reflection.PropertyInfo item in result.GetType().GetProperties())
                    {
                        string propname = item.Name;
                        if (propname.ToLower() == "createdon")
                        {
                            continue;
                        }
                        object propValue = item.GetValue(value);
                        if (propValue != null || Convert.ToString(propValue).Length != 0)
                        {
                            db.Entry(value).Property(propname).IsModified = true;
                        }
                    }

                    value.LastModifiedOn = System.DateTime.Now;
                    db.Entry(value).Property(x => x.LastModifiedOn).IsModified = true;
                }

                //Save and Complete
                db.SaveChanges();
                scope.Complete();
            }
            return(db.TEDocuments.Find(result.Uniqueid));
        }
Exemplo n.º 3
0
        public TEComment Post(TEComment value)
        {
            TEComment result = value;

            if (!(value.Uniqueid + "".Length > 0))
            {
                result.CreatedOn      = System.DateTime.Now;
                result.LastModifiedOn = System.DateTime.Now;
                result = db.TEComments.Add(value);
            }
            else
            {
                db = new TEHRIS_DevEntities();
                db.TEComments.Attach(value);


                foreach (System.Reflection.PropertyInfo item in result.GetType().GetProperties())
                {
                    string propname = item.Name;
                    if (propname.ToLower() == "createdon")
                    {
                        continue;
                    }
                    object propValue = item.GetValue(value);
                    if (propValue != null || Convert.ToString(propValue).Length != 0)
                    {
                        db.Entry(value).Property(propname).IsModified = true;
                    }
                }

                value.LastModifiedOn = System.DateTime.Now;
                db.Entry(value).Property(x => x.LastModifiedOn).IsModified = true;
            }

            db.SaveChanges();

            return(db.TEComments.Find(value.Uniqueid));
        }
        public TENotification AddNotifications(TENotification value)
        {
            try
            {
                TENotification result = value;

                if (!(value.Uniqueid + "".Length > 0))
                {
                    //Create
                    result.CreatedOn      = System.DateTime.Now;
                    result.LastModifiedOn = System.DateTime.Now;
                    result = db.TENotifications.Add(value);
                }
                else
                {
                    //IEnumerable<TENotification> updatenotif  = (db.TENotifications.Where(x=>(x.SendBy == value.SendBy)&&(x.ReadStatus == false)));

                    //foreach (System.Reflection.PropertyInfo value1 in updatenotif.GetType().GetProperties())
                    //{
                    //    //Edit
                    //    TENotification value1 = updatenotif(;
                    //    db = new TEHRIS_DevEntities();
                    //    db.TENotifications.Attach(value1);
                    //    foreach (System.Reflection.PropertyInfo item in result.GetType().GetProperties())
                    //    {
                    //        string propname = item.Name;
                    //        if (propname.ToLower() == "createdon")
                    //            continue;
                    //        object propValue = item.GetValue(value);
                    //        if (propValue != null || Convert.ToString(propValue).Length != 0)
                    //            db.Entry(value).Property(propname).IsModified = true;
                    //    }

                    //    value.LastModifiedOn = System.DateTime.Now;
                    //    db.Entry(value).Property(x => x.LastModifiedOn).IsModified = true;
                    //    db.SaveChanges();
                    //}
                    if (value.ReceivedBy != null)
                    {
                        foreach (var some in db.TENotifications.Where(x => (x.ReceivedBy == value.ReceivedBy) && (x.ReadStatus == false)).ToList())
                        {
                            some.ReadStatus     = true;
                            some.LastModifiedOn = System.DateTime.Now;
                        }
                    }
                    else
                    {
                        //Edit
                        db = new TEHRIS_DevEntities();
                        db.TENotifications.Attach(value);
                        foreach (System.Reflection.PropertyInfo item in result.GetType().GetProperties())
                        {
                            string propname = item.Name;
                            if (propname.ToLower() == "createdon")
                            {
                                continue;
                            }
                            object propValue = item.GetValue(value);
                            if (propValue != null || Convert.ToString(propValue).Length != 0)
                            {
                                db.Entry(value).Property(propname).IsModified = true;
                            }
                        }

                        value.LastModifiedOn = System.DateTime.Now;
                        db.Entry(value).Property(x => x.LastModifiedOn).IsModified = true;
                    }
                }
            }
            catch (Exception ex)
            {
                db.ApplicationErrorLogs.Add(
                    new ApplicationErrorLog
                {
                    Error             = ex.Message,
                    ExceptionDateTime = System.DateTime.Now,
                    InnerException    = ex.InnerException != null ? ex.InnerException.Message : "",
                    Source            = "From TENotifications API | AddNotifications | " + this.GetType().ToString(),
                    Stacktrace        = ex.StackTrace
                }
                    );
            }

            db.SaveChanges();
            return(db.TENotifications.Find(value.Uniqueid));
        }
        public TEUnit_Onboarding AddTEUnitOnboarding(TEUnit_Onboarding value)
        {
            TEUnit_Onboarding result = value;



            if (!(value.Uniqueid + "".Length > 0))
            {
                //Create
                result.CreatedOn      = System.DateTime.Now;
                result.LastModifiedOn = System.DateTime.Now;
                result = db.TEUnit_Onboarding.Add(value);
            }
            else
            {
                //Edit
                db = new TEHRIS_DevEntities();
                db.TEUnit_Onboarding.Attach(value);
                foreach (System.Reflection.PropertyInfo item in result.GetType().GetProperties())
                {
                    string propname = item.Name;
                    if (propname.ToLower() == "createdon")
                    {
                        continue;
                    }
                    object propValue = item.GetValue(value);
                    if (propValue != null || Convert.ToString(propValue).Length != 0)
                    {
                        db.Entry(value).Property(propname).IsModified = true;
                    }
                }

                value.LastModifiedOn = System.DateTime.Now;
                db.Entry(value).Property(x => x.LastModifiedOn).IsModified = true;

                if (value.Status == "Active")
                {
                    db.Configuration.ProxyCreationEnabled = false;
                    TEUnit_Onboarding unit = db.TEUnit_Onboarding.Where(x => x.Uniqueid == value.Uniqueid).ToList().First();
                    if (unit != null)
                    {
                        string email = (from teuser in db.UserProfiles
                                        where (teuser.UserId == unit.UserID)
                                        select teuser.email).ToList().First();
                        //string tecontact = (from teoint in db.TEContacts
                        //                    where ((teoint.Emailid == email) && (teoint.Projectid == value.Project) && (teoint.Unitid == value.Unit))
                        //                    select teoint.CallName).ToList().First();
                        //if (tecontact == null)
                        try
                        {
                            TEContact contact = db.TEContacts.Where(x => (x.Emailid == email) &&
                                                                    (x.Projectid == value.Project) &&
                                                                    (x.Unitid == value.Unit)).ToList().First();
                            if (contact != null)
                            {
                                SendContact(value);
                            }
                        }
                        catch (Exception ex)
                        { SendContact(value);
                          ex.Message.ToString(); }
                    }
                }
            }

            db.SaveChanges();

            //CRUD Mobile
            //CRUD Email
            //CRUD Address

            return(db.TEUnit_Onboarding.Find(value.Uniqueid));
        }