Esempio n. 1
0
        public HttpResponseMessage Put(TimeSheet exp)
        {
            TimeManagementEntities context = new TimeManagementEntities();
            TimeSheet temp = context.TimeSheet.Where(x => x.ID == exp.ID).SingleOrDefault();

            //temp.Notes = HttpUtility.HtmlDecode(exp.Notes);
            //temp.DateOfSheet = exp.DateOfSheet;
            //temp.TotalTime= exp.TotalTime;
            //temp.CreatedDate = exp.CreatedDate;
            if (temp.IsDeleted == true)
            {
                var resp = new HttpResponseMessage(HttpStatusCode.NotFound);
                return(resp);
            }
            else
            {
                temp.Notes       = HttpUtility.HtmlEncode(exp.Notes);
                temp.TotalTime   = exp.TotalTime;
                temp.DateOfSheet = exp.DateOfSheet;
                temp.CreatedDate = exp.CreatedDate;
                repository.Update(temp);
                var resp = new HttpResponseMessage(HttpStatusCode.OK);
                return(resp);
            }
        }
        public OperationStatus UpdateProjectStatus(int ProjectId, string Status)
        {
            OperationStatus status = OperationStatus.Error;

            try
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    if (ProjectId != 0)
                    {
                        var rs = dbcontext.tblProjectMemberAssociations.FirstOrDefault(x => x.ProjectMemberAssociationId == ProjectId);
                        if (rs != null)
                        {
                            rs.Status = Status;
                            dbcontext.SaveChanges();
                            status = OperationStatus.Success;
                        }
                    }
                    else
                    {
                        status = OperationStatus.Error;
                    }
                }
            }
            catch (Exception ex)
            {
                dbcontext.Dispose();
                status = OperationStatus.Exception;
                throw ex;
            }

            return(status);
        }
Esempio n. 3
0
        public OperationStatus DeleteSprint(int SprintId)
        {
            OperationStatus status = OperationStatus.Error;

            try
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    if (SprintId != 0)
                    {
                        var rs = dbcontext.tblProjectSprints.FirstOrDefault(x => x.SprintId == SprintId);
                        if (rs != null)
                        {
                            dbcontext.tblProjectSprints.Remove(rs);
                            dbcontext.SaveChanges();
                            status = OperationStatus.Success;
                        }
                    }
                    else
                    {
                        status = OperationStatus.Error;
                    }
                }
            }
            catch (Exception ex)
            {
                dbcontext.Dispose();
                status = OperationStatus.Exception;
                throw ex;
            }

            return(status);
        }
Esempio n. 4
0
        private bool TryGetPrincipal(string username, string password, out IPrincipal principal)
        {
            // this is the method that does the authentication

            //users often add a copy/paste space at the end of the username
            username = username.Trim();
            password = password.Trim();

            //TODO
            //Replace this with your own Authentication Code

            TimeManagementEntities context = new TimeManagementEntities();
            User user = context.User.Where(x => x.Email == username).SingleOrDefault();

            //AccountManagement.ApiLogin(username, password);

            if (user != null)
            {
                // once the user is verified, assign it to an IPrincipal with the identity name and applicable roles
                String[] roles = { "Administrator" };
                principal = new GenericPrincipal(new GenericIdentity(username), roles);

                return(true);
            }
            else
            {
                if (!String.IsNullOrWhiteSpace(username))
                {
                }
                principal = null;
                return(false);
            }
        }
        public OperationStatus AddNewSprintMemberTimeAssociation(SprintMemberTimeAssociationCustomModel model)
        {
            OperationStatus status = OperationStatus.Error;

            try
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    if (model.TimeId == 0)
                    {
                        tblSprintMemberTimeAssociation _addSprintList = new tblSprintMemberTimeAssociation
                        {
                            SprintId    = model.SprintId,
                            MemberId    = model.MemberId,
                            TimeSpend   = model.TimeSpend,
                            DDate       = model.DDate,
                            Description = model.Description,

                            IsActive     = true,
                            IsDeleted    = false,
                            CreatedBy    = model.CreatedBy,
                            CreatedDate  = DateTime.Now,
                            ModifiedBy   = model.ModifiedBy,
                            ModifiedDate = DateTime.Now,
                        };
                        dbcontext.tblSprintMemberTimeAssociations.Add(_addSprintList);
                        dbcontext.SaveChanges();

                        status = OperationStatus.Success;
                    }
                    else
                    {
                        var rs = dbcontext.tblSprintMemberTimeAssociations.FirstOrDefault(x => x.TimeId == model.TimeId);
                        if (rs != null)
                        {
                            rs.MemberId    = model.MemberId;
                            rs.SprintId    = model.SprintId;
                            rs.TimeSpend   = model.TimeSpend;
                            rs.DDate       = model.DDate;
                            rs.Description = model.Description;

                            rs.ModifiedDate = DateTime.Now;
                            rs.ModifiedBy   = model.ModifiedBy;

                            dbcontext.SaveChanges();
                            status = OperationStatus.Success;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                dbcontext.Dispose();
                status = OperationStatus.Exception;
                throw ex;
            }

            return(status);
        }
        public ActionResult Report(string id, string fromDate, string toDate, string searchString)
        {
            LocalReport lr   = new LocalReport();
            string      path = Path.Combine(Server.MapPath("~/"), "Report2.rdlc");

            if (System.IO.File.Exists(path))
            {
                lr.ReportPath = path;
            }
            else
            {
                return(View("Index"));
            }

            using (TimeManagementEntities context = new TimeManagementEntities())
            {
                int userid = context.User.Where(x => x.Email == LoggedInUser.loggedInUserEmail && x.IsDeleted == false).Select(u => u.ID).SingleOrDefault();

                List <TimeSheet> cn = context.TimeSheet.Where(x => x.UserID == userid && x.IsDeleted == false).ToList();
                ReportDataSource rd = new ReportDataSource("TimeManagementDataSet", listForReport);
                lr.DataSources.Add(rd);
            }



            string reportType = id;
            string mimeType;
            string encoding;
            string fileNameExtension;


            string deviceInfo =

                "<DeviceInfo>" +
                "  <OutputFormat>" + id + "</OutputFormat>" +
                "  <PageWidth>8.5in</PageWidth>" +
                "  <PageHeight>11in</PageHeight>" +
                "  <MarginTop>0.5in</MarginTop>" +
                "  <MarginLeft>1in</MarginLeft>" +
                "  <MarginRight>1in</MarginRight>" +
                "  <MarginBottom>0.5in</MarginBottom>" +
                "</DeviceInfo>";

            Warning[] warnings;
            string[]  streams;
            byte[]    renderedBytes;

            renderedBytes = lr.Render(
                reportType,
                deviceInfo,
                out mimeType,
                out encoding,
                out fileNameExtension,
                out streams,
                out warnings);
            return(File(renderedBytes, mimeType));
        }
Esempio n. 7
0
        public void Post(TimeSheet timesheet)
        {
            TimeManagementEntities context = new TimeManagementEntities();

            //  TimeSheet temp = new TimeSheet();
            timesheet.Notes = HttpUtility.HtmlEncode(timesheet.Notes);
            //timesheet.DateOfSheet = timesheet.DateOfSheet;
            //timesheet.TotalTime = timesheet.TotalTime;
            //timesheet.CreatedDate = timesheet.CreatedDate;
            repository.Add(timesheet);
        }
        public object GetMyProjectList(int MemberId)
        {
            IList <ProjectMemberAssociationCustomModel> ProjectListModel = new List <ProjectMemberAssociationCustomModel>();

            using (response = new Response())
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    try
                    {
                        if (MemberId != 0)
                        {
                            response.success = true;
                            ProjectListModel = dbcontext.tblProjectMemberAssociations.Where(x => x.MemberId == MemberId && x.IsDeleted == false)
                                               .Select(x => new ProjectMemberAssociationCustomModel
                            {
                                ProjectMemberAssociationId = x.ProjectMemberAssociationId,
                                ProjectId    = x.ProjectId,
                                ProjectName  = x.tblProject != null ? x.tblProject.Title : "",
                                MemberId     = x.MemberId,
                                MemberName   = x.tblMember != null ? x.tblMember.FName + " " + x.tblMember.LName: "",
                                Description  = x.Description,
                                StartDate    = x.StartDate,
                                EndDate      = x.EndDate,
                                Status       = x.Status,
                                IsActive     = x.IsActive,
                                IsDeleted    = x.IsDeleted,
                                CreatedBy    = x.CreatedBy,
                                CreatedDate  = x.CreatedDate,
                                ModifiedBy   = x.ModifiedBy,
                                ModifiedDate = x.ModifiedDate,
                            }).OrderByDescending(x => x.ProjectId).ToList();

                            return(ProjectListModel);
                        }
                        else
                        {
                            response.success = false;
                            return(ProjectListModel);
                        }
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        return(response);
                    }
                }
            }
        }
Esempio n. 9
0
        public object GetMemberDetail(int MemberId)
        {
            using (response = new Response())
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    try
                    {
                        response.success = true;
                        var rs = dbcontext.tblMembers.Where(x => x.IsDeleted == false && x.MemberId == MemberId)
                                 .Select(x => new MemberCustomModel
                        {
                            MemberId     = x.MemberId,
                            FName        = x.FName,
                            LName        = x.LName,
                            MemberCode   = x.MemberCode,
                            EmailId      = x.EmailId,
                            MobileNo     = x.MobileNo,
                            MotherName   = x.MotherName,
                            FatherName   = x.FatherName,
                            Address      = x.Address,
                            DateOfBirth  = x.DateOfBirth,
                            Gender       = x.Gender,
                            Designation  = x.Designation,
                            UserTypeId   = x.UserTypeId,
                            Image        = x.Image,
                            IsActive     = x.IsActive,
                            IsDeleted    = x.IsDeleted,
                            CreatedBy    = x.CreatedBy,
                            CreatedDate  = x.CreatedDate,
                            ModifiedBy   = x.ModifiedBy,
                            ModifiedDate = x.ModifiedDate,

                            SprintList = x.tblSprintMemberAssociations.Where(s => s.MemberId == x.MemberId).Select(s => new SprintDetail {
                                SprintName = s.tblProjectSprint != null ? s.tblProjectSprint.Title : ""
                            }).ToList(),
                        }).OrderByDescending(x => x.MemberId).ToList();

                        return(rs);
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        return(response);
                    }
                }
            }
        }
        public object GetMySprintList(int MemberId)
        {
            List <SprintMemberAssociationCustomModel> SprintListModel = new List <SprintMemberAssociationCustomModel>();

            using (response = new Response())
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    try
                    {
                        if (MemberId != 0)
                        {
                            response.success = true;
                            SprintListModel  = dbcontext.tblSprintMemberAssociations.Where(x => x.MemberId == MemberId && x.IsDeleted == false)
                                               .Select(x => new SprintMemberAssociationCustomModel
                            {
                                SprintMemberAssociationId = x.SprintMemberAssociationId,
                                SprintId    = x.SprintId,
                                SprintName  = x.tblProjectSprint != null ? x.tblProjectSprint.Title : "",
                                MemberId    = x.MemberId,
                                MemberName  = x.tblMember != null ? x.tblMember.FName + " " + x.tblMember.LName : "",
                                Description = x.tblProjectSprint.Description,
                                StartDate   = x.tblProjectSprint.StartDate,
                                EndDate     = x.tblProjectSprint.EndDate,
                                Status      = x.Status,
                                IsActive    = x.IsActive,
                                ProjectId   = x.tblProjectSprint != null ? x.tblProjectSprint.ProjectId : null,
                                //TotalTimeSpent =  (dbcontext.tblSprintMemberTimeAssociations.Where(y => y.SprintId == x.SprintId && y.MemberId == x.MemberId).Select(v => new tblSprintMemberTimeAssociation { TimeSpend = v.TimeSpend}).Sum())
                                TotalTimeSpent = (dbcontext.tblSprintMemberTimeAssociations.Where(y => y.SprintId == x.SprintId && y.MemberId == x.MemberId).Sum(v => v.TimeSpend))
                            }).OrderByDescending(x => x.SprintMemberAssociationId).ToList();

                            return(SprintListModel);
                        }
                        else
                        {
                            response.success = false;
                            return(SprintListModel);
                        }
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        return(response);
                    }
                }
            }
        }
Esempio n. 11
0
        public object GetApplicationMemberList(MemberCustomModel objMemberModel)
        {
            IList <MemberCustomModel> MemberListModel = new List <MemberCustomModel>();

            using (response = new Response())
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    try
                    {
                        response.success = true;
                        MemberListModel  = dbcontext.tblMembers.Where(x => x.IsDeleted == false)
                                           .Select(x => new MemberCustomModel
                        {
                            MemberId     = x.MemberId,
                            FName        = x.FName,
                            LName        = x.LName,
                            MemberCode   = x.MemberCode,
                            UserTypeId   = x.UserTypeId,
                            EmailId      = x.EmailId,
                            MobileNo     = x.MobileNo,
                            MotherName   = x.MotherName,
                            FatherName   = x.FatherName,
                            Address      = x.Address,
                            DateOfBirth  = x.DateOfBirth,
                            Gender       = x.Gender,
                            Designation  = x.Designation,
                            Image        = x.Image,
                            IsActive     = x.IsActive,
                            IsDeleted    = x.IsDeleted,
                            CreatedBy    = x.CreatedBy,
                            CreatedDate  = x.CreatedDate,
                            ModifiedBy   = x.ModifiedBy,
                            ModifiedDate = x.ModifiedDate,
                        }).OrderByDescending(x => x.MemberId).ToList();

                        return(MemberListModel);
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        return(response);
                    }
                }
            }
        }
Esempio n. 12
0
        public OperationStatus ForgotPassword(ForgotPasswordCustomModel model)
        {
            OperationStatus status = OperationStatus.Error;

            try
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    var rs = dbcontext.tblApplicationUsers.FirstOrDefault(x => x.UserName == model.UserName);
                    if (rs != null)
                    {
                        string from = "*****@*****.**";  //any valid GMail ID
                        string to   = Convert.ToString(rs.EmailId); //any valid GMail ID
                        using (MailMessage mail = new MailMessage(from, to))
                        {
                            mail.Subject = "Time Management Forgot Password";
                            mail.Body    = "Dear " + rs.FName + " " + rs.LName + " <br><br>Please use this password to login: "******"<br><br>Thanks,<br>Team";

                            mail.IsBodyHtml = true;
                            SmtpClient smtp = new SmtpClient();
                            smtp.Host = "smtp.gmail.com";
                            smtp.Port = 587;
                            smtp.UseDefaultCredentials = false;
                            smtp.Credentials           = new System.Net.NetworkCredential
                                                             ("*****@*****.**", "shally123");// Enter seders User name and password
                            smtp.EnableSsl = true;
                            smtp.Send(mail);

                            status = OperationStatus.Success;
                        }
                    }
                    else
                    {
                        status = OperationStatus.Duplicate;
                    }
                }
            }
            catch (Exception ex)
            {
                dbcontext.Dispose();
                status = OperationStatus.Exception;
                throw ex;
            }

            return(status);
        }
Esempio n. 13
0
        public object GetProjectListing(ProjectCustomModel objProjectModel)
        {
            List <ProjectCustomModel> ProjectListModel = new List <ProjectCustomModel>();

            using (response = new Response())
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    try
                    {
                        response.success = true;
                        ProjectListModel = dbcontext.tblProjects.Where(x => x.IsDeleted == false)
                                           .Select(x => new ProjectCustomModel
                        {
                            ProjectId   = x.ProjectId,
                            Title       = x.Title,
                            Description = x.Description,
                            Documents   = x.Documents,
                            Image       = x.Image,
                            StartDate   = x.StartDate,
                            EndDate     = x.EndDate,
                            AlliasName  = x.AlliasName,
                            ProjectType = x.ProjectType,
                            MemberList  = x.tblProjectMemberAssociations.Where(s => s.ProjectId == x.ProjectId).Select(s => new ProjectMembers {
                                MemberName = s.tblMember != null ? s.tblMember.FName + " " + s.tblMember.LName: ""
                            }).ToList(),

                            IsActive     = x.IsActive,
                            IsDeleted    = x.IsDeleted,
                            CreatedBy    = x.CreatedBy,
                            CreatedDate  = x.CreatedDate,
                            ModifiedBy   = x.ModifiedBy,
                            ModifiedDate = x.ModifiedDate,
                        }).OrderByDescending(x => x.ProjectId).ToList();

                        return(ProjectListModel);
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        return(response);
                    }
                }
            }
        }
        public OperationStatus AddNewProjectMemberAssociation(ProjectMemberAssociationCustomModel objProjectMemberModel)
        {
            OperationStatus status = OperationStatus.Error;

            try
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    if (objProjectMemberModel.ProjectMemberAssociationId == 0)
                    {
                        if (objProjectMemberModel.ProjectMemberList != null)
                        {
                            List <tblProjectMemberAssociation> entityKisanLIst = objProjectMemberModel.ProjectMemberList.Select(m => new tblProjectMemberAssociation
                            {
                                ProjectId   = objProjectMemberModel.ProjectId,
                                MemberId    = m.ProjectMemberId,
                                StartDate   = objProjectMemberModel.StartDate,
                                EndDate     = objProjectMemberModel.EndDate,
                                Description = objProjectMemberModel.Description,
                                Status      = objProjectMemberModel.Status == null ? "1" : objProjectMemberModel.Status,
                                IsActive    = true,
                                IsDeleted   = false,
                            }).ToList();

                            dbcontext.tblProjectMemberAssociations.AddRange(entityKisanLIst);
                            dbcontext.SaveChanges();
                            status = OperationStatus.Success;
                        }
                    }
                    else
                    {
                        status = OperationStatus.Error;
                    }
                }
            }
            catch (Exception ex)
            {
                dbcontext.Dispose();
                status = OperationStatus.Exception;
                throw ex;
            }

            return(status);
        }
        public ActionResult Index(string fromDate, string toDate, string searchString)
        {
            string g = fromDate + " " + toDate + " " + searchString;
            String fromDateForSQL = String.Empty;
            String toDateForSQL   = String.Empty;

            if (fromDate != "" && toDate != "")
            {
                String fromDD = fromDate.Substring(0, 2);
                String fromMM = fromDate.Substring(3, 2);
                String fromYY = fromDate.Substring(6, 4);
                fromDateForSQL = fromYY + "/" + fromMM + "/" + fromDD;

                String toDD = toDate.Substring(0, 2);
                String toMM = toDate.Substring(3, 2);
                String toYY = toDate.Substring(6, 4);
                toDateForSQL = toYY + "/" + toMM + "/" + toDD;

                using (TimeManagementEntities context = new TimeManagementEntities())
                {
                    DateTime dtFrom = Convert.ToDateTime(fromDateForSQL);
                    DateTime dtTo   = Convert.ToDateTime(toDateForSQL);
                    int      userid = context.User.Where(x => x.Email == LoggedInUser.loggedInUserEmail && x.IsDeleted == false).Select(u => u.ID).SingleOrDefault();

                    var v = context.TimeSheet.Where(x => (x.DateOfSheet >= dtFrom.Date && x.DateOfSheet <= dtTo.Date) && x.UserID == userid && x.IsDeleted == false && x.Notes.Contains(searchString)).ToList();
                    listForReport = (List <TimeSheet>)v;
                    return(View(v));
                }
            }
            else
            {
                using (TimeManagementEntities context = new TimeManagementEntities())
                {
                    int userid = context.User.Where(x => x.Email == LoggedInUser.loggedInUserEmail && x.IsDeleted == false).Select(u => u.ID).SingleOrDefault();

                    var v = context.TimeSheet.Where(x => x.UserID == userid && x.IsDeleted == false && x.Notes.Contains(searchString)).ToList();
                    listForReport = (List <TimeSheet>)v;
                    return(View(v));
                }
            }

            return(null);
        }
Esempio n. 16
0
        public object GetProjectSprintListing(int ProjectId)
        {
            List <SprintCustomModel> SprintListModel = new List <SprintCustomModel>();

            using (response = new Response())
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    try
                    {
                        response.success = true;
                        SprintListModel  = dbcontext.tblProjectSprints.Where(x => x.ProjectId == ProjectId)
                                           .Select(x => new SprintCustomModel
                        {
                            ProjectId    = x.ProjectId,
                            Title        = x.Title,
                            Description  = x.Description,
                            SprintNo     = x.SprintNo,
                            Status       = x.Status,
                            SprintId     = x.SprintId,
                            StartDate    = x.StartDate,
                            EndDate      = x.EndDate,
                            IsActive     = x.IsActive,
                            IsDeleted    = x.IsDeleted,
                            CreatedBy    = x.CreatedBy,
                            CreatedDate  = x.CreatedDate,
                            ModifiedBy   = x.ModifiedBy,
                            ModifiedDate = x.ModifiedDate,
                        }).OrderByDescending(x => x.SprintId).ToList();

                        return(SprintListModel);
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        return(response);
                    }
                }
            }
        }
Esempio n. 17
0
        public object GetSprintListing(int SprintId)
        {
            List <SprintCustomModel> SprintListModel = new List <SprintCustomModel>();

            using (response = new Response())
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    try
                    {
                        response.success = true;
                        SprintListModel  = dbcontext.tblProjectSprints.Where(x => x.SprintId == SprintId)
                                           .Select(x => new SprintCustomModel
                        {
                            SprintId    = x.SprintId,
                            ProjectId   = x.ProjectId,
                            Title       = x.Title,
                            Description = x.Description,
                            SprintNo    = x.SprintNo,
                            Status      = x.Status,
                            StartDate   = x.StartDate,
                            EndDate     = x.EndDate,
                            MemberList  = x.tblSprintMemberAssociations.Where(s => s.SprintId == x.SprintId).Select(s => new SprintMembers {
                                MemberId = s.MemberId, MemberName = s.tblMember != null ? s.tblMember.FName + " " + s.tblMember.LName : "", TotalTimeSpent = (dbcontext.tblSprintMemberTimeAssociations.Where(y => y.SprintId == x.SprintId && y.MemberId == s.tblMember.MemberId).Sum(v => v.TimeSpend))
                            }).ToList(),
                            //TotalTimeSpent = (dbcontext.tblSprintMemberTimeAssociations.Where(y => y.SprintId == x.SprintId && y.MemberId == x.MemberId).Sum(v => v.TimeSpend))
                        }).OrderByDescending(x => x.SprintId).ToList();

                        return(SprintListModel);
                    }
                    catch (Exception ex)
                    {
                        response.success = false;
                        response.message = ex.Message;
                        return(response);
                    }
                }
            }
        }
Esempio n. 18
0
        public OperationStatus AddNewSprint(SprintCustomModel model)
        {
            OperationStatus status = OperationStatus.Error;

            try
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    if (model.SprintId == 0)
                    {
                        var rs = dbcontext.tblProjectSprints.FirstOrDefault(x => x.Title == model.Title && x.ProjectId == model.ProjectId);
                        if (rs == null)
                        {
                            tblProjectSprint _addSprint = new tblProjectSprint
                            {
                                ProjectId    = model.ProjectId,
                                Title        = model.Title,
                                Description  = model.Description,
                                SprintNo     = model.SprintNo,
                                Status       = model.Status,
                                StartDate    = model.StartDate,
                                EndDate      = model.EndDate,
                                IsActive     = true,
                                IsDeleted    = false,
                                CreatedDate  = DateTime.Now,
                                CreatedBy    = model.CreatedBy,
                                ModifiedDate = DateTime.Now,
                                ModifiedBy   = model.ModifiedBy,
                            };
                            dbcontext.tblProjectSprints.Add(_addSprint);
                            dbcontext.SaveChanges();

                            status = OperationStatus.Success;
                        }
                        else
                        {
                            status = OperationStatus.Duplicate;
                        }
                    }
                    else
                    {
                        var rs = dbcontext.tblProjectSprints.FirstOrDefault(x => x.SprintId == model.SprintId);
                        if (rs != null)
                        {
                            rs.Title       = model.Title;
                            rs.Description = model.Description;
                            rs.SprintNo    = model.SprintNo;
                            rs.Status      = model.Status;
                            rs.StartDate   = model.StartDate;
                            rs.EndDate     = model.EndDate;

                            dbcontext.SaveChanges();
                            status = OperationStatus.Success;
                        }
                        else
                        {
                            status = OperationStatus.Duplicate;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                dbcontext.Dispose();
                status = OperationStatus.Exception;
                throw ex;
            }

            return(status);
        }
        /// <summary>
        /// method is used for validate application users
        /// </summary>
        /// <param name="Logininfo"></param>
        /// <returns></returns>
        public object GetLoginUser(LoginUserModel Logininfo)
        {
            APIResponse       _response        = new APIResponse();
            LoggedInUserModel lgAppUserDetails = new LoggedInUserModel();
            object            objLgAppUserDetails;

            try
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    Logininfo.UserName = Logininfo.UserName.ToLower();
                    tblApplicationUser lgDetail = dbcontext.tblApplicationUsers.FirstOrDefault(x => x.UserName.ToLower() == Logininfo.UserName && x.IsDeleted == false);

                    if (lgDetail != null)
                    {
                        if (lgDetail.Password == Logininfo.Password)
                        {
                            lgAppUserDetails.ApplicationUserId = lgDetail.ApplicationUserId;
                            lgAppUserDetails.UserIdentityKey   = lgDetail.UserIdentityKey;
                            lgAppUserDetails.success           = true;
                            lgAppUserDetails.ErrorMessage      = "User Authenticated!!";
                            lgAppUserDetails.FName             = lgDetail.FName == null ? "" : lgDetail.FName;
                            lgAppUserDetails.LName             = lgDetail.LName == null ? "" : lgDetail.LName;
                            lgAppUserDetails.MemberCode        = lgDetail.MemberCode == null ? "" : lgDetail.MemberCode;
                            lgAppUserDetails.UserTypeId        = lgDetail.UserTypeId == null ? 0 : lgDetail.UserTypeId;
                            lgAppUserDetails.EmailId           = lgDetail.EmailId;
                            lgAppUserDetails.MobileNo          = lgDetail.MobileNo;
                            lgAppUserDetails.Address           = lgDetail.Address;
                            lgAppUserDetails.Gender            = lgDetail.Gender;
                            lgAppUserDetails.DateOfBirth       = lgDetail.DateOfBirth;
                            lgAppUserDetails.FatherName        = lgDetail.tblMember == null ? "" : lgDetail.tblMember.FatherName;
                            lgAppUserDetails.MotherName        = lgDetail.tblMember == null ? "" : lgDetail.tblMember.MotherName;
                            lgAppUserDetails.UserTypeId        = lgDetail.UserTypeId;
                            lgAppUserDetails.UserName          = lgDetail.UserName;

                            _response.Message  = "User Authenticated!!";
                            _response.IsSucess = true;
                        }
                        else
                        {
                            lgAppUserDetails.ErrorMessage = "Invalid password!!";
                            _response.Message             = "Invalid password!!";
                            _response.IsSucess            = false;
                        }
                    }
                    else
                    {
                        lgAppUserDetails.ErrorMessage = "Invalid username!!";
                        _response.Message             = "Invalid username!!";
                        _response.IsSucess            = false;
                    }
                }
            }
            catch (Exception ex)
            {
                lgAppUserDetails              = null;
                objLgAppUserDetails           = null;
                dbcontext                     = null;
                lgAppUserDetails.ErrorMessage = ex.Message.ToString();
            }
            objLgAppUserDetails = lgAppUserDetails;
            return(objLgAppUserDetails);
        }
        /// <summary>
        /// This method is used to save new members
        /// </summary>
        /// <returns></returns>
        public OperationStatus SaveApplicationUser(ApplicationUserModel applicationUserModel)
        {
            OperationStatus status = OperationStatus.Error;

            using (TransactionScope ts = new TransactionScope())
            {
                try
                {
                    using (dbcontext = new TimeManagementEntities())
                    {
                        if (applicationUserModel.ApplicationUserId == 0)
                        {
                            var rs = dbcontext.tblApplicationUsers.FirstOrDefault(x => x.UserName == applicationUserModel.UserName && x.IsDeleted == false);
                            if (rs == null)
                            {
                                tblMember _addMember = new tblMember
                                {
                                    FName        = applicationUserModel.FName,
                                    LName        = applicationUserModel.LName,
                                    MemberCode   = applicationUserModel.MemberCode,
                                    UserTypeId   = applicationUserModel.UserTypeId,
                                    EmailId      = applicationUserModel.EmailId,
                                    MobileNo     = applicationUserModel.MobileNo,
                                    Address      = applicationUserModel.Address,
                                    Gender       = applicationUserModel.Gender,
                                    DateOfBirth  = applicationUserModel.DateOfBirth,
                                    FatherName   = applicationUserModel.FatherName,
                                    MotherName   = applicationUserModel.MotherName,
                                    Designation  = applicationUserModel.Designation,
                                    Image        = applicationUserModel.Image,
                                    IsActive     = true,
                                    IsDeleted    = false,
                                    CreatedDate  = DateTime.Now,
                                    CreatedBy    = applicationUserModel.CreatedBy,
                                    ModifiedDate = DateTime.Now,
                                    ModifiedBy   = applicationUserModel.ModifiedBy,
                                };
                                dbcontext.tblMembers.Add(_addMember);
                                dbcontext.SaveChanges();
                                int userid = _addMember.MemberId;

                                tblApplicationUser _applicationUserinfo = new tblApplicationUser
                                {
                                    FName           = applicationUserModel.FName,
                                    LName           = applicationUserModel.LName,
                                    MemberCode      = applicationUserModel.MemberCode,
                                    UserTypeId      = applicationUserModel.UserTypeId,
                                    EmailId         = applicationUserModel.EmailId,
                                    MobileNo        = applicationUserModel.MobileNo,
                                    Address         = applicationUserModel.Address,
                                    Gender          = applicationUserModel.Gender,
                                    DateOfBirth     = applicationUserModel.DateOfBirth,
                                    UserIdentityKey = userid,
                                    UserName        = applicationUserModel.UserName,
                                    Password        = applicationUserModel.Password,

                                    IsActive     = true,
                                    IsDeleted    = false,
                                    CreatedDate  = DateTime.Now,
                                    CreatedBy    = applicationUserModel.CreatedBy,
                                    ModifiedDate = DateTime.Now,
                                    ModifiedBy   = applicationUserModel.ModifiedBy,
                                };

                                dbcontext.tblApplicationUsers.Add(_applicationUserinfo);
                                dbcontext.SaveChanges();

                                status = OperationStatus.Success;
                                ts.Complete();
                            }
                            else
                            {
                                status = OperationStatus.Duplicate;
                                //ts.Dispose();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    dbcontext.Dispose();
                    status = OperationStatus.Exception;
                    ts.Dispose();
                    throw ex;
                }
            }
            return(status);
        }
Esempio n. 21
0
        public OperationStatus AddNewProject(ProjectCustomModel objProjectModel)
        {
            OperationStatus status = OperationStatus.Error;

            try
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    if (objProjectModel.ProjectId == 0)
                    {
                        var rs = dbcontext.tblProjects.FirstOrDefault(x => x.Title == objProjectModel.Title && x.IsDeleted == false);
                        if (rs == null)
                        {
                            tblProject _addProject = new tblProject
                            {
                                Title       = objProjectModel.Title,
                                Description = objProjectModel.Description,
                                Documents   = objProjectModel.Documents,
                                Image       = objProjectModel.Image,
                                StartDate   = objProjectModel.StartDate,
                                EndDate     = objProjectModel.EndDate,
                                AlliasName  = objProjectModel.AlliasName,
                                ProjectType = objProjectModel.ProjectType,

                                IsActive     = true,
                                IsDeleted    = false,
                                CreatedDate  = DateTime.Now,
                                CreatedBy    = objProjectModel.CreatedBy,
                                ModifiedDate = DateTime.Now,
                                ModifiedBy   = objProjectModel.ModifiedBy,
                            };
                            dbcontext.tblProjects.Add(_addProject);
                            dbcontext.SaveChanges();

                            status = OperationStatus.Success;
                        }
                        else
                        {
                            status = OperationStatus.Duplicate;
                        }
                    }
                    else
                    {
                        var rs = dbcontext.tblProjects.FirstOrDefault(x => x.ProjectId == objProjectModel.ProjectId && x.IsDeleted == false);
                        if (rs != null)
                        {
                            rs.Title        = objProjectModel.Title;
                            rs.Description  = objProjectModel.Description;
                            rs.Documents    = objProjectModel.Documents;
                            rs.Image        = objProjectModel.Image;
                            rs.StartDate    = objProjectModel.StartDate;
                            rs.EndDate      = objProjectModel.EndDate;
                            rs.AlliasName   = objProjectModel.AlliasName;
                            rs.ProjectType  = objProjectModel.ProjectType;
                            rs.ModifiedDate = DateTime.Now;

                            dbcontext.SaveChanges();
                            status = OperationStatus.Success;
                        }
                        else
                        {
                            status = OperationStatus.Duplicate;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                dbcontext.Dispose();
                status = OperationStatus.Exception;
                throw ex;
            }

            return(status);
        }
        public OperationStatus AddNewSprintMemberAssociation(SprintMemberAssociationCustomModel objSprintMemberModel)
        {
            OperationStatus status = OperationStatus.Error;

            try
            {
                using (dbcontext = new TimeManagementEntities())
                {
                    if (objSprintMemberModel.SprintMemberAssociationId == 0)
                    {
                        if (objSprintMemberModel.SprintMemberList != null)
                        {
                            List <tblSprintMemberAssociation> entitySprintLIst = objSprintMemberModel.SprintMemberList.Select(m => new tblSprintMemberAssociation
                            {
                                SprintId    = objSprintMemberModel.SprintId,
                                MemberId    = m.SprintMemberId,
                                StartDate   = objSprintMemberModel.StartDate,
                                EndDate     = objSprintMemberModel.EndDate,
                                Description = objSprintMemberModel.Description,
                                Status      = objSprintMemberModel.Status == null ? "1" : objSprintMemberModel.Status,
                                IsActive    = true,
                                IsDeleted   = false,
                            }).ToList();

                            dbcontext.tblSprintMemberAssociations.AddRange(entitySprintLIst);
                            dbcontext.SaveChanges();
                            status = OperationStatus.Success;
                        }

                        //var rs = dbcontext.tblSprintMemberAssociations.FirstOrDefault(x => x.IsDeleted == false && x.SprintId == objSprintMemberModel.SprintId && x.MemberId == objSprintMemberModel.MemberId);
                        //if (rs == null)
                        //{
                        //    tblSprintMemberAssociation _addSprintist = new tblSprintMemberAssociation
                        //    {
                        //        SprintId = objSprintMemberModel.SprintId,
                        //        MemberId = objSprintMemberModel.MemberId,
                        //        StartDate = objSprintMemberModel.StartDate,
                        //        EndDate = objSprintMemberModel.EndDate,
                        //        Description = objSprintMemberModel.Description,
                        //        Status = objSprintMemberModel.Status == null ? "1" : objSprintMemberModel.Status,
                        //        IsActive = true,
                        //        IsDeleted = false,
                        //        CreatedBy = objSprintMemberModel.CreatedBy,
                        //        CreatedDate = System.DateTime.Now,
                        //        ModifiedBy = objSprintMemberModel.ModifiedBy,
                        //        ModifiedDate = System.DateTime.Now,
                        //    };
                        //    dbcontext.tblSprintMemberAssociations.Add(_addSprintist);
                        //    dbcontext.SaveChanges();

                        //    status = OperationStatus.Success;
                        //}
                        //else
                        //{
                        //    status = OperationStatus.Duplicate;
                        //}
                    }
                    else
                    {
                        status = OperationStatus.Error;
                    }
                }
            }
            catch (Exception ex)
            {
                dbcontext.Dispose();
                status = OperationStatus.Exception;
                throw ex;
            }

            return(status);
        }