Beispiel #1
0
        public Member DeleteMember(string username) // Return null for any errors otherwise Member(deleted)
        {
            Member member = context.Member.Where(m => m.Username == username).FirstOrDefault();

            //context.Member.FindAsync()
            if (member != null)
            {
                context.Member.Remove(member);
                context.SaveChanges();
            }
            return(member); // To inform user.
        }
Beispiel #2
0
 public ReturnModel AddPrivateTalkMessage(PrivateTalkMessage privateTalkMessage) // Return -1 for any errors otherwise 0
 {
     try
     {
         context.PrivateTalkMessage.Add(privateTalkMessage);
         context.SaveChanges();
     }
     catch { return(new ReturnModel {
             ErrorCode = ErrorCodes.DatabaseError
         }); }
     return(new ReturnModel {
         ErrorCode = ErrorCodes.OK, ReturnedId = privateTalkMessage.MessageId
     });                                                                                               // Return TaskId(autoset from identity)
 }
Beispiel #3
0
 public ReturnModel AddQuickTodoComment(QuickTaskComment quickTaskComment)
 {
     try
     {
         context.QuickTaskComment.Add(quickTaskComment);
         context.SaveChanges();
     }
     catch { return(new ReturnModel {
             ErrorCode = ErrorCodes.DatabaseError
         }); }
     return(new ReturnModel {
         ErrorCode = ErrorCodes.OK, ReturnedId = quickTaskComment.MessageId
     });                                                                                            // Autoset in DB
 }
 public ReturnModel AddProjectToDoComment(ProjectTaskComment projectTaskComment)
 {
     try
     {
         context.ProjectTaskComment.Add(projectTaskComment);
         context.SaveChanges();
     }
     catch { return(new ReturnModel {
             ErrorCode = ErrorCodes.DatabaseError
         }); }
     return(new ReturnModel {
         ErrorCode = ErrorCodes.OK, ReturnedId = projectTaskComment.MessageId
     });                                                                                              // Autoset in DB
 }
        public ReturnModel UpdateMySetting(MemberSetting setting)
        {
            MemberSetting mSetting = context.MemberSetting.Where(mS => mS.Username == setting.Username).FirstOrDefault();

            if (mSetting == null)
            {
                return(new ReturnModel {
                    ErrorCode = ErrorCodes.ItemNotFoundError
                });
            }

            try
            {
                mSetting.SwitchMode           = setting.SwitchMode;
                mSetting.Theme                = setting.Theme;
                mSetting.OwnerReporting       = setting.OwnerReporting;
                mSetting.AssignedToReporting  = setting.AssignedToReporting;
                context.Entry(mSetting).State = EntityState.Modified;
                context.SaveChanges();
            }
            catch { return(new ReturnModel {
                    ErrorCode = ErrorCodes.DatabaseError
                }); }
            return(new ReturnModel {
                ErrorCode = ErrorCodes.OK
            });
        }
Beispiel #6
0
        public ReturnModel NewProject(Project project) // Return -1 for any errors otherwise ProjectId
        {
            //Implement ModelState in Controller action methods.
            try
            {
                context.Project.Add(project);
                context.SaveChanges();
            }
            catch { return(new ReturnModel {
                    ErrorCode = ErrorCodes.DatabaseError
                }); }

            return(new ReturnModel {
                ErrorCode = ErrorCodes.OK, ReturnedId = project.ProjectId
            });                                                                                   // Provides ProjectID(identity autoset from db)
        }
        public ProjectTask Complete(long toDoId)
        {
            ProjectTask pTask = ProjectToDos.Where(pt => pt.TaskId == toDoId).FirstOrDefault();

            if (pTask != null)
            {
                try
                {
                    pTask.IsCompleted          = true; // Set as done
                    pTask.Finish               = DateTimeOffset.Now;
                    context.Entry(pTask).State = EntityState.Modified;
                    context.SaveChanges();
                    return(pTask);
                }
                catch { }
            }
            return(null);
        }
Beispiel #8
0
        public ReturnModel NewLicense(MemberLicense memberLicense)
        {
            try
            {
                context.MemberLicense.Add(memberLicense);

                MemberLicenseUsedStorage mlus = new MemberLicenseUsedStorage {
                    LicenseId = memberLicense.LicenseId, AzureSaUsedSizeInBytes = 1
                };
                context.MemberLicenseUsedStorage.Add(mlus);

                context.SaveChanges();
            }
            catch { return(new ReturnModel {
                    ErrorCode = ErrorCodes.DatabaseError
                }); }
            return(new ReturnModel {
                ErrorCode = ErrorCodes.OK, Model = memberLicense.LicenseId
            });                                                                                    // Provides TeamId(identity autoset from db)
        }
Beispiel #9
0
 public ReturnModel AddTeamMember(TeamMember teamMember, string thisMember) // Return -1 for any errors otherwise 0
 {
     try
     {
         if (this.CanSendMoreTeamMemberRequest(thisMember))
         {
             context.TeamMember.Add(teamMember);
             context.SaveChanges();
             return(new ReturnModel {
                 ErrorCode = ErrorCodes.OK, ReturnedId = teamMember.TeamMemberId
             });
         }
         else
         {
             return(new ReturnModel {
                 ErrorCode = ErrorCodes.Forbidden
             });
         }
     }
     catch { return(new ReturnModel {
             ErrorCode = ErrorCodes.DatabaseError
         }); }
 }
Beispiel #10
0
 public ReturnModel NewTeam(Team team) // Return -1 for any errors otherwise TeamID
 {
     try
     {
         if (this.CanCreateNewTeam(team.Owner))
         {
             context.Team.Add(team);
             context.SaveChanges();
         }
         else
         {
             return(new ReturnModel {
                 ErrorCode = ErrorCodes.Forbidden
             });
         }
     }
     catch { return(new ReturnModel {
             ErrorCode = ErrorCodes.DatabaseError
         }); }
     return(new ReturnModel {
         ErrorCode = ErrorCodes.OK, ReturnedId = team.TeamId
     });                                                                             // Provides TeamId(identity autoset from db)
 }
 public ReturnModel NewPrivateTalkLastSeen(PrivateTalkLastSeen privateTalkLastSeen)
 {
     try
     {
         PrivateTalkLastSeen PTLastSeen = PrivateTalkLastSeen.Where(ptls => ptls.PrivateTalkId == privateTalkLastSeen.PrivateTalkId && ptls.Visitor == privateTalkLastSeen.Visitor).FirstOrDefault();
         if (PTLastSeen != null)
         {
             PTLastSeen.LastSeen             = privateTalkLastSeen.LastSeen;
             context.Entry(PTLastSeen).State = EntityState.Modified;
             context.SaveChanges();
         }
         else
         {   //Runs only once.
             context.PrivateTalkLastSeen.Add(privateTalkLastSeen);
             context.SaveChanges();
         }
     }
     catch { return(new ReturnModel {
             ErrorCode = ErrorCodes.DatabaseError
         }); }
     return(new ReturnModel {
         ErrorCode = ErrorCodes.OK
     });
 }
Beispiel #12
0
        public QuickTask Complete(long quickTaskId, string username)
        {
            QuickTask qTask = QuickToDos.Where(qT => qT.TaskId == quickTaskId).FirstOrDefault();

            if (qTask != null)
            {
                try
                {
                    qTask.Completedby          = username;
                    context.Entry(qTask).State = EntityState.Modified;
                    context.SaveChanges();
                    return(qTask);
                }
                catch { }
            }
            return(null);
        }
Beispiel #13
0
        public ReturnModel Register(RegisterModel registerModel) //Return -2 if user already exists error has ocurred or MemberId, -1 for db errors.
        {
            Member member = Members.Where(m => m.Username == registerModel.Username || m.Email == registerModel.Email).FirstOrDefault();

            if (member != null)
            {
                return(new ReturnModel {
                    ErrorCode = ErrorCodes.MemberAlreadyExistsError
                });                                                                         // -2
            }
            try
            {
                Member newMember = new Member
                {
                    Username    = registerModel.Username,
                    Name        = registerModel.Name,
                    Surname     = registerModel.Surname,
                    CellCountry = registerModel.CellCountry,
                    Cell        = registerModel.Cell,
                    Email       = registerModel.Email,
                    Avatar      = registerModel.Avatar
                };

                (newMember.CryptoPassword, newMember.CryptoSalt) = cryptoHelpers.EncryptWithPBKDF2(registerModel.Password);

                context.Member.Add(newMember); //New member(5 properties) is OK.

                // CREATE DATABASE MEMBER SETTING RECORD
                string[] temalar = new string[] { "ArashiyamaBambulari", "Venedik", "Peribacalari", "Orman", "Yaprak", "Kedi", "Deniz", "Denizalti", "Brienz", "Bulutlar", "TropicalGunisigi", "DenizAgac", "Bulutlar", "Tarla" };
                Random   r       = new Random();

                string randomItem = temalar[r.Next() % temalar.Length];

                MemberSetting mSetting = new MemberSetting {
                    Username = registerModel.Username, Theme = randomItem
                };
                context.MemberSetting.Add(mSetting);
                // END OF CREATE DATABASE MEMBER SETTING RECORD

                // //CREATE TRIAL LICENSE
                // MemberLicense trialLicense = new MemberLicense();
                // trialLicense.Username = registerModel.Username;
                // trialLicense.StartDate = DateTimeOffset.Now;
                // trialLicense.EndDate = trialLicense.StartDate.AddDays(15); // 2 Haftalık Deneme Lisansı
                // trialLicense.NumberOfEmployees = 10;
                // trialLicense.Address = "Deneme Lisansı";
                // trialLicense.AzureSaConnectionString = "Deneme Lisansı";
                // trialLicense.AzureSaSizeInGb = 20;
                // trialLicense.Company = "Deneme Lisansı";
                // trialLicense.Currency = "TL";
                // trialLicense.Fee = 1;
                // trialLicense.LicenseType = "kurumsal";

                // this.licenses.NewLicense(trialLicense);

                //END TRIAL LICENSE
                context.SaveChanges(); // canceled async

                try
                {
                    this.SendThankYouEmail(registerModel).Wait(5000); // wait max 5sn
                }
                catch { }

                long MemberId = 0; // Use if needed(autoset from db)
                return(new ReturnModel {
                    ErrorCode = ErrorCodes.OK, ReturnedId = MemberId
                });                                                                          //ID
            }
            catch { return(new ReturnModel {
                    ErrorCode = ErrorCodes.DatabaseError
                }); }                                                                   // -1
        }