Esempio n. 1
0
        public DataResult <MembersDetail> GetMyProfile(string societyId, string MemberId)
        {
            DataResult <MembersDetail> Result = new DataResult <MembersDetail>();

            using (var db = new SocietyDBEntities())
            {
                MembersDetail objMembers = db.MembersDetails.Where(x => x.societyId == societyId && x.memberId == MemberId).FirstOrDefault();

                if (objMembers != null)
                {
                    List <MembersDetail> ObjMemberDetailsList = new List <MembersDetail>();
                    ObjMemberDetailsList.Add(objMembers);
                    Result.Data    = ObjMemberDetailsList;
                    Result.Message = "Data Viewed Successfully";
                    Result.MsgType = "S";
                }
                else
                {
                    Result.Message = "Member Not Found.";
                    Result.MsgType = "E";
                }
            }

            return(Result);
        }
Esempio n. 2
0
        public async Task <ActionResult <MembersDetail> > PostMembersDetail(MembersDetail membersDetail)
        {
            _context.MembersDetails.Add(membersDetail);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetMembersDetail", new { id = membersDetail.MemberDetailId }, membersDetail));
        }
Esempio n. 3
0
        public DataResult <MembersDetail> UpdateEmail(MembersDetail objMembersDetail)
        {
            DataResult <MembersDetail> Result = new DataResult <MembersDetail>();

            try
            {
                using (var db = new SocietyDBEntities())
                {
                    //var transaction = db.Database.BeginTransaction();
                    MembersDetail objMember = db.MembersDetails.Where(x => x.memberId == objMembersDetail.memberId && x.societyId == objMembersDetail.societyId).FirstOrDefault();

                    if (objMember != null)
                    {
                        objMember.email           = objMembersDetail.email;
                        db.Entry(objMember).State = System.Data.EntityState.Modified;
                        db.SaveChanges();
                    }
                    else
                    {
                        Result.Message = "Member Not Found.";
                        Result.MsgType = "E";
                    }
                }
            }
            catch (Exception ex)
            {
                Result.Message = ex.Message;
                Result.MsgType = "E";
            }

            return(Result);
        }
Esempio n. 4
0
        public async Task <IActionResult> PutMembersDetail(int id, MembersDetail membersDetail)
        {
            if (id != membersDetail.MemberDetailId)
            {
                return(BadRequest());
            }

            _context.Entry(membersDetail).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MembersDetailExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 5
0
        public DataResult <MembersDetail> CheckLogin(string userName, string password, string societyId)
        {
            DataResult <MembersDetail> Result = new DataResult <MembersDetail>();

            try
            {
                using (var db = new SocietyDBEntities())
                {
                    MembersDetail objMembersDetail = db.MembersDetails.Where(x => x.userName == userName && x.password == password && x.societyId == societyId).FirstOrDefault();

                    if (objMembersDetail != null)
                    {
                        Result.Message = "Login Successfull.";
                        Result.MsgType = "S";
                    }
                    else
                    {
                        Result.Message = "Incorrect Username/Password.";
                        Result.MsgType = "E";
                    }
                }
            }
            catch (Exception ex)
            {
                Result.Message = ex.Message;
                Result.MsgType = "E";
            }
            return(Result);
        }
Esempio n. 6
0
        public DataResult <MembersDetail> AddMember(MembersDetail objMembersDetail)
        {
            DataResult <MembersDetail> Result = new DataResult <MembersDetail>();

            try
            {
                using (var db = new SocietyDBEntities())
                {
                    MembersDetail objMemberExists = db.MembersDetails.Where(x => x.flatNo == objMembersDetail.flatNo && x.societyId == objMembersDetail.societyId && x.isDeleted == false).FirstOrDefault();

                    if (objMemberExists == null)
                    {
                        MembersDetail objMemberUsernameExist = db.MembersDetails.Where(x => x.userName == objMembersDetail.userName).FirstOrDefault();

                        if (objMemberUsernameExist == null)
                        {
                            if (objMembersDetail.memberType != "SC")
                            {
                                DataResult <NumRange> ResultMemberID = Gb.GetNumRange("MB");

                                if (ResultMemberID.MsgType == "S")
                                {
                                    objMembersDetail.memberId = ResultMemberID.StringResult;
                                }
                                else
                                {
                                    Result.Message = ResultMemberID.Message;
                                    Result.MsgType = "E";
                                    return(Result);
                                }
                            }
                            objMembersDetail.createdDate = DateTime.Now;
                            objMembersDetail.isDeleted   = false;
                            db.MembersDetails.Add(objMembersDetail);
                            db.SaveChanges();

                            Result.Message = "Data Saved Successfully.";
                            Result.MsgType = "S";
                        }
                        else
                        {
                            Result.Message = "Username Already Exists.";
                            Result.MsgType = "E";
                        }
                    }
                    else
                    {
                        Result.Message = "This Flat Is Owned By Another Member.";
                        Result.MsgType = "E";
                    }
                }
            }
            catch (Exception ex)
            {
                Result.Message = ex.Message;
                Result.MsgType = "E";
            }
            return(Result);
        }
        public HttpResponseMessage UpdateEmail(MembersDetail objMembersDetail)
        {
            DataResult <MembersDetail> Result = new DataResult <MembersDetail>();

            Result   = objMemberRepo.UpdateEmail(objMembersDetail);
            Response = Request.CreateResponse <DataResult <MembersDetail> >(HttpStatusCode.Created, Result);
            return(Response);
        }
Esempio n. 8
0
        public DataResult <AddSocietyCustomModel> AddSociety(AddSocietyCustomModel objSociety)
        {
            DataResult <AddSocietyCustomModel> Result = new DataResult <AddSocietyCustomModel>();

            try
            {
                using (var db = new SocietyDBEntities())
                {
                    SocietyDetail objSocetyExists = db.SocietyDetails.Where(x => x.societyCode == objSociety.societyCode).FirstOrDefault();

                    if (objSocetyExists == null)
                    {
                        MembersDetail objMemberUsernameExist = db.MembersDetails.Where(x => x.userName == objSociety.userName).FirstOrDefault();

                        if (objMemberUsernameExist == null)
                        {
                            DataResult <NumRange> ResultSocietyID = Gb.GetNumRange("SC");

                            if (ResultSocietyID.MsgType == "S")
                            {
                                var societyId = ResultSocietyID.StringResult;

                                DataResult <NumRange> ResultMemberID = Gb.GetNumRange("MB");

                                if (ResultMemberID.MsgType == "S")
                                {
                                    var           memberId         = ResultMemberID.StringResult;
                                    SocietyDetail objSocietyDetail = new SocietyDetail();
                                    objSocietyDetail.societyId   = societyId;
                                    objSocietyDetail.societyCode = objSociety.societyCode;
                                    objSocietyDetail.societyName = objSociety.societyName;
                                    objSocietyDetail.secretory   = memberId;
                                    objSocietyDetail.address     = objSociety.address;
                                    objSocietyDetail.createdBy   = objSociety.createdBy;
                                    objSocietyDetail.createdDate = DateTime.Now;
                                    objSocietyDetail.isDeleted   = false;
                                    db.SocietyDetails.Add(objSocietyDetail);
                                    db.SaveChanges();

                                    MembersDetail objMembersDetail = new MembersDetail();
                                    objMembersDetail.memberId   = memberId;
                                    objMembersDetail.memberName = objSociety.memberName;
                                    objMembersDetail.userName   = objSociety.userName;
                                    objMembersDetail.password   = objSociety.password;
                                    objMembersDetail.mobileNo   = objSociety.mobileNo;
                                    objMembersDetail.memberType = objSociety.memberType;
                                    objMembersDetail.flatNo     = objSociety.flatNo;
                                    objMembersDetail.email      = objSociety.email;
                                    objMembersDetail.societyId  = societyId;
                                    objMembersDetail.createdBy  = objSociety.createdBy;

                                    MemberRepository           objMemberRepo = new MemberRepository();
                                    DataResult <MembersDetail> ResultMember  = objMemberRepo.AddMember(objMembersDetail);

                                    if (ResultMember.MsgType == "S")
                                    {
                                        Result.Message = "Data Saved Successfully.";
                                        Result.MsgType = "S";
                                    }
                                    else
                                    {
                                        Result.Message = ResultMember.Message;
                                        Result.MsgType = "E";
                                        return(Result);
                                    }
                                }
                                else
                                {
                                    Result.Message = ResultMemberID.Message;
                                    Result.MsgType = "E";
                                }
                            }
                            else
                            {
                                Result.Message = ResultSocietyID.Message;
                                Result.MsgType = "E";
                            }
                        }
                        else
                        {
                            Result.Message = "Username Already Exists.";
                            Result.MsgType = "E";
                        }
                    }
                    else
                    {
                        Result.Message = "Society Code Already Exists.";
                        Result.MsgType = "E";
                    }
                }
            }
            catch (Exception ex)
            {
                Result.Message = ex.Message;
                Result.MsgType = "E";
            }
            return(Result);
        }